wood burning stoves 2.0*
The moose likes Struts and the fly likes displayTag: how to use checkBox with struts2? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "displayTag: how to use checkBox with struts2?" Watch "displayTag: how to use checkBox with struts2?" New topic

displayTag: how to use checkBox with struts2?

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
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.

* 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

Joined: Jan 28, 2008
Posts: 460
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.

Visit my blog: http://jnassef.blogspot.com/
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
"%myid[myindex]}" is invalid code. I tried that (intuitively) and it didn't work.
Taeil Yoon

Joined: Oct 10, 2005
Posts: 1
Here is my working source.....!!

<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"/>

I agree. Here's the link: http://aspose.com/file-tools
subject: displayTag: how to use checkBox with struts2?
Similar Threads
struts2 + display tags + maps
checkBox in a list: How to associate the ID to the check box?
maintin checkbox stauts during paginatin(dispalytag)
how to add link to display:table to a method in the DispatchAction class
checkbox using displaytag