Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

displayTag: how to use checkBox with struts2?

 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is very confusing. I have the following table:


myid is a list of Long [23,62,13,67,21,61] (private Long[] myid)
userCheck (private String[] userCheck

this doesn't work.
I tried different ways - nothing.

note:
* when I do this: fieldValue='%{myid[2]}' //the 2 is an example - I get the right ID (ie, the correct result).

* when trying to use "${myindex.myid}" (just as suggested in a different thread in this forum) I get the string itself (ie ${myindex...}

does anyone know how to solve this issue?
 
Alaa Nassef
Ranch Hand
Posts: 471
Hibernate Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I read "%{myindex.myid}" I understand that you have a bean/map called "myindex" in a scope viewable by the page, and "myid" is the name of a property/key in this bean/map. From what I understand of what you explained, this is not the case. You should use "%myid[myindex]}", where "myid" is the name of your array, and "myindex" is the index number you want. If you need to display all IDs, just loop on the array, and change the index to display several check boxes.
 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"%myid[myindex]}" is invalid code. I tried that (intuitively) and it didn't work.
 
Taeil Yoon
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my working source.....!!

<s:form>
<s:set name="list" value="adminMembers" scope="request"/>

<display:table name="list" class="simple" export="false" id="list" pagesize="10" >
<display:column><s:checkbox name="userid" theme="simple" fieldValue="%{#attr.list.userid}" value="false"></s:checkbox></display:column>
<display:column property="userid" escapeXml="true"/>
<display:column property="name" escapeXml="true"/>
</display:table>

</s:form>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic