java - How to check list.contains in jsp using struts 2 tags -



java - How to check list.contains in jsp using struts 2 tags -

i need show series of check boxes , if status succeeded, need check them. below code. have regions hashmap , selectedregions array list. iterating on regions map, , displaying checkboxes text next value regions map. now, while iterating, if value of regions map available in array list, need create check box checked. else united nations checked. tried 1 shown below. not working.

class="lang-xml prettyprint-override"><s:iterator value="regions"> <li> <div class="listclass"> <s:if test="#regions.value==selectedregions.value"> <input type="checkbox" id='mytheater' checked="checked" name="theatercheckbox" class="theatercheckbox" /> <s:property value="value" /> </s:if> <s:else> <input type="checkbox" id='mytheater' name="theatercheckbox" class="theatercheckbox" /> <s:property value="value" /> </s:else> </div> <div class="checkboxdiv"> <input type="checkbox" id="allfeatured" class="featuredcheckbox" /> </div> </li> </s:iterator>

some how, if status using not working. please allow me know how attain this?

there many ways this. should check out <s:checkbox/> , <s:checkboxlist/> tags;

also note follow dry, set <s:if> around checked="checked" part only, since rest same.

keeping simple, code as-is, 1 way consists in using ognl's in (contains) , ognl's {} (list projection) follows:

class="lang-xml prettyprint-override"><s:iterator value="regions"> <li> <div class="listclass"> <input type = "checkbox" id = "mytheater" <s:if test="%{value in selectedregions.{value}}"> checked = "checked" </s:if> name = "theatercheckbox" class = "theatercheckbox" /> <s:property value="value" /> </div> <div class="checkboxdiv"> <input type="checkbox" id="allfeatured" class="featuredcheckbox" /> </div> </li> </s:iterator>

java jsp struts2 ognl

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -