• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

checkbox using displaytag

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Struts 2, don't use a c:out 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 ]
 
Swathi Ram
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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....
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<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.
 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic