Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 select default selection

 
rohant paralikar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
it worked
thanks!
 
Maki Jav
Ranch Hand
Posts: 446
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What property type you set in action class?


Thanks,

Maki Jav
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic