• 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

Display tag problem

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am listing values in jsp page using display tag using struts2.

In the jsp page i am using html checkbox element .
based on the list value i need to checkbox to be checked, otherwise unchecked.
if the value is true it should be checked if the value is false then unchecked
can you help me out?
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use EL like placing the code below in your checkbox tag
 
sudhir pavan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i tried like this but nothing selected

<input type="checkbox" value="${true == data.isread ? 'checked' : ''}" />
 
Saloon Keeper
Posts: 7590
177
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remove "true == ".
 
sudhir pavan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
same result . nothing got selected

<input type="checkbox" value="${data.isread ? 'checked' : ''}" />
 
Tim Moores
Saloon Keeper
Posts: 7590
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's the value of "data.isread" ? (Note that I'm not asking what you think it is, but what you verified it is in the JSP page.)
 
sudhir pavan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
true / false

if its true then the checkbox should be selected
if its flase then the checkbox should not be selected
 
Tim Moores
Saloon Keeper
Posts: 7590
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, that much is obvious, because otherwise you couldn't use it in a "X ? Y : Z" statement.

But you said that nothing gets selected which I took to mean that for some element "checked" should be printed, but for some reason is not. That's not what you meant?

If it *is* what you meant, then verify that the value of "data.isread" for that particular element is what you think it is. (Note that "isread" would not trigger if the method in your bean is called "isRead".)
 
Nikhil Padharia
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
don't write EL inside value
Make it like



Also try making it data.isread == true or different combinations if it does not work properly
 
sudhir pavan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry nikhil it shows me error like "Unterminated <s:checkbox tag "
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Struts 2 , you can use the <s:checkbox> tag to create a HTML check box. The fieldValue=”true” is the actual value that will be submitted by the check box.
Just go through it this will really helpful for you. www.mkyong.com/struts2/struts-2-scheckbox-checkbox-example/
 
Nikhil Padharia
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@sudhir pavan - it shouldn't , Post the entire <s:checkbox tag you are writing..
reply
    Bookmark Topic Watch Topic
  • New Topic