开发者

Stryts-JQuery Plugin Issue With Double Select

I have the following code to do a doubleselect using Struts2 and the jquery plugin:

jsp:

<s:url id="ajaxActionUrl" value="/getStateCodesJson"/>
<sj:select name="stateCodeId"
           id="stateCodeId"
           label="State"
           href="%{ajaxActionUrl}"
           onChangeTopics="reloadSecondSelect"
           list="stateCodeList"
           listKey="id"
           listValue="label"
           emptyOption="true"
           headerKey="-1"
           headerValue="Please Select A State"/>

<sj:select name="subCodeId"
           id="subCodeId"
           label="Sub Feature"
           href="%{ajaxActionUrl}"
           formIds="mapGeneratorForm"
           reloadTopics="reloadSecondSelect"
           list="subCodeList"
           listKey="id"
   开发者_JAVA技巧        listValue="subCodeDescription"
           emptyOption="true"
           headerKey="-1"
           headerValue="Please Select A Code"/>

Action:

@Action(value = "getStateCodesJson", results = {
        @Result(name = "success", type = "json")
})
public String getStateCodesJson() throws Exception {
    stateCodeList = stateCodeService.getAll();
    Collections.sort(stateCodeList);

    if (stateCodeId != null) {
        StateCode stateCode = stateCodeService.getById(stateCodeId);
        subCodeList = subCodeService.getByStateCode(stateCode);
    }

    return SUCCESS;
}

When the jsp first loads, the getStateCodesJson() method is called 3 times. However, after making the change, the action is not called again, so the second never gets populated.

Can anyone assist?

Jason


Handle the null value of the second list at the action itself, rather than transferring it to the DAO.

Else you can use a struts2 double select tag.

Here is a good example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜