English 中文(简体)
STRUTS2和AJAX——选择国家,居住国
原标题:STRUTS2 and AJAX - Select the country, populate the States
  • 时间:2012-04-27 13:02:03
  •  标签:
  • ajax
  • struts2

在选择国家之后,我要向各州展示。

JSP

       <s:select label="COUNTRY" name="summaryData.addressCountry" id="addForm_countryCode" 
                                      list="loyaltyCountryMap" tabindex="" headerKey="US" headerValue="United States"
                                      listKey="key" listValue="value.countryName" 
                                      onchange="getStateList( #addForm_countryCode )">

       </s:select> 

<s:select label="STATE" name="summaryData.addressCityCode" headerValue="-Select-" headerKey="-Select-" list="stateList" required="true" cssClass="storedPaymentInput_size1 required" id="stateList"/>

马达加斯加

  function getStateList() {
        var countryCode = $( #addForm_countryCode").val(); 
        $.ajax({
            url:  ajaxStateList ,
            dataType:  html ,
            data: { countryCode : countryCode},
            success: function(data) {
                $( #stateList ).html( data );
            }
        });
    }

STRUTS.XML

     <action name="ajaxStateList" class="actions.AjaxStateList">
       <result name="success"/>
 </action>

行动

 private List<String> stateList;

    private String countryCode;

    public String getCountryCode() {
        return countryCode;
    }

    public void setCountryCode(String countryCode) {
        this.countryCode = countryCode;
    }

    public List<String> getStateList() {
        return stateList;
    }

    public void setStateList(List<String> stateList) {
        this.stateList = stateList;
    }

    public String execute() {

        LoyaltyStateProvinces.getInstance();

        stateList = StateProvinces.getAllStateProvinceByCountryCode(countryCode);

        for(StateProvince state: states){
            stateList.add(state.getStateProvinceCode());
        }


        return SUCCESS;
    }

我如何利用AJAX+Struts2开展工作?

最佳回答
问题回答

暂无回答




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签