wood burning stoves 2.0*
The moose likes Struts and the fly likes checkbox using displaytag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "checkbox using displaytag" Watch "checkbox using displaytag" New topic
Author

checkbox using displaytag

Swathi Ram
Greenhorn

Joined: Sep 18, 2007
Posts: 27
I need to pass the officeId when I click on the checkbox to my action class. I can get a true value but not the officeid. Anybody having any information on this, please help. Below is the code in my jsp.


<s:set name="offices" value="offices" scope="request"/>
<display:table name="offices" requestURI="" pagesize="${row}" sort="list"
id="jobResults" class="candSearchResults" export="true" >
<display:column><s:checkbox name="checked" value='<c ut value="%{office.officeId}"/>'/></display:column>
<display:column property="office.officeId" title="ID" sort="true"/>
</display:table>
[ September 18, 2007: Message edited by: Bear Bibeault ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
In Struts 2, don't use a cut tag to show a dynamic value. Just use the %{} expression. Also, the attribute you need to use to set the value of a s:checkbox tag is fieldValue, not value. Example:

For more information on the s:checkbox tag, see the Struts 2 tag reference.
[ September 18, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Swathi Ram
Greenhorn

Joined: Sep 18, 2007
Posts: 27
Thank you for responding . But still i'm getting the count of selected check boxes. I'm not getting the value of the officeid.Here is my jsp

<s:set name="offices" value="offices" scope="request"/>
<display:table name="offices" requestURI="" pagesize="${row}" sort="list" id="jobResults" class="candSearchResults" >
<display:column><s:checkbox name="checked" fieldValue='%{office.officeId}'/></display:column>
<display:column property="office.officeId" title="ID" sort="true"/>
<display:column property="office.officeName" href="testing.action" paramId="officeStatus" paramProperty="office.officeId" title="Name" sort="true"/>


This is my action class where I want selected offices ids

private String[] checked;
ArrayList checkBoxes=new ArrayList();
for (int i=0; i<(checked.length); i++) {
checkBoxes.add(checked[i]);
System.out.println("list of office ids "+checkBoxes.get(i));
}
System.out.println("Size of check box" +checkBoxes.size());

Here I can print the size of check boxes but not the office ids.

Please help me....
swathi vellanki
Greenhorn

Joined: Sep 18, 2007
Posts: 2
<s:checkbox name="checked" fieldValue='%{office.officeId}' />

I tried this but it doesn't work inside the display tags.
<display:column><s:checkbox theme="simple" name="checked" fieldValue="%{office.officeId}" /></display:column>

I can't get the office id to my action class.
Could you please help me.
lynn fann
Ranch Hand

Joined: Oct 15, 2006
Posts: 115
try to change to EL tag

that is:
<s-el:checkbox name="checked" fieldValue='%{office.officeId}' />

http://struts.apache.org/1.x/struts-el/struts-el.html
Swathi Ram
Greenhorn

Joined: Sep 18, 2007
Posts: 27
The above option works, but it still doesn't pick up the value.
In my action class it picks up the correct number of checkboxes i checked, but it doesn't have any value. Not even true or false. I want to pass a unique officeid to the checkbox value.
Can the <s-el:> tag work within the <display:column> tag.

Thanks in advance...
Swathi Ram
Greenhorn

Joined: Sep 18, 2007
Posts: 27
Thanks for all the help.

I just had to access the value from the table id. And it works.

<display:table name="offices" requestURI="" pagesize="${row}" sort="list" id="jobResults" class="candSearchResults" >
<display:column><s:checkbox theme="simple" name="checked" fieldValue="${jobResults.office.officeid}"/></display:column>

</display:table>
prasad nuthalapati
Greenhorn

Joined: Sep 28, 2007
Posts: 1
Swathi,
I am having the same issue which you had with check box in displaytag. I couldn't understand how you are reading the value in the action. Can you please help me with this


Thanks
Prasad
Grace Phone
Greenhorn

Joined: Sep 29, 2011
Posts: 9
Swathi Ram wrote:Thanks for all the help.

I just had to access the value from the table id. And it works.

<display:table name="offices" requestURI="" pagesize="${row}" sort="list" id="jobResults" class="candSearchResults" >
<display:column><s:checkbox theme="simple" name="checked" fieldValue="${jobResults.office.officeid}"/></display:column>

</display:table>


Thanks for the quick fix.
I do like this to access the value into combo box using Table id.
Cheers.


Regards,
Grace
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: checkbox using displaytag