Stryts-JQuery 插件双重选择问题
我有以下代码来使用 Struts2 和 jquery 插件进行双重选择:
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"
listValue="subCodeDescription"
emptyOption="true"
headerKey="-1"
headerValue="Please Select A Code"/>
操作:
@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;
}
当 jsp 首次加载时, getStateCodesJson() 方法被调用 3 次。但是,进行更改后,不会再次调用该操作,因此第二个操作永远不会被填充。
有人可以帮忙吗?
贾森
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"
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在操作本身处理第二个列表的空值,而不是将其传输到 DAO。
否则你可以使用 struts2 双选标签。
这里是一个很好的例子。
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.