<html:multibox> equivalent in Struts 2

纵然是瞬间 提交于 2019-12-02 12:19:48

问题


Below is the html tag multibox which i want to migrate it to struts 2

<html:multibox name="unitForm" property="eservices">
    <bean:write name="service"/>
</html:multibox>

as it is checkbox so thought of using simple checkbox which is in the iterator so i used below code

<s:checkbox theme="simple" name="unitForm.eservices"></s:checkbox>

in action

String[] toArray = new String[selectedadminVOs.size()];
unitForm.setEservices(selectedadminVOs.toArray(toArray));

stuck here,without or minimal changes in action code how can i migrate it to struts2


回答1:


The equivalent in Strust2 is

<s:iterator var="row" value="%{unitForm.eservices}">
    <input type="checkbox" name="unitForm.checked" 
        value="${row.service}" ${unitForm.checked.contains(row.service)?'checked="checked"':''}/>    
</s:iterator>

or you can use s:property tag

<s:iterator var="row" value="%{unitForm.eservices}">
    <input type="checkbox" name="unitForm.checked" 
        value="${row.service}" <s:property value="%{unitForm.checked.contains(#row.service)?'checked="checked"':''}"/>/>    
</s:iterator>


来源:https://stackoverflow.com/questions/26629210/htmlmultibox-equivalent-in-struts-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!