File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "displayTag: how to use checkBox with struts2?" Watch "displayTag: how to use checkBox with struts2?" New topic
Author

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.

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

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
Greenhorn

Joined: Oct 10, 2005
Posts: 1
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>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: displayTag: how to use checkBox with struts2?