• 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

Struts2 select default selection

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using struts2 and jsp as development envionment.
I have a select tag on my jsp wherein i need to ,
1. Make a default selection depending on my bean/action class's property value.
if the property is 1 then i need to select Yes and if its 0 then i need to display No to the user.
2. Also when the form is submitted i need to pass the value in revese way to the bean i.e if selected is Yes pass 1 else 0.
i am able to do the 2nd one but not the first, i.e getting the default selection and displaying it.
does anybody know how to do it?

Thanks & Regards,
-Rohant
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just call an action that forwards to this JSP, and in that action, declare a property with the same name as the name used in the s:select tag and set it to 0 or 1. This will automatically cause the correct value to be selected when the JSP is displayed.
 
rohant paralikar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it worked
thanks!
 
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

What property type you set in action class?


Thanks,

Maki Jav
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic