File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts2 select default selection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 select default selection" Watch "Struts2 select default selection" New topic

Struts2 select default selection

rohant paralikar

Joined: Jun 18, 2008
Posts: 4
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,
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.

Consultant, Sima Solutions
rohant paralikar

Joined: Jun 18, 2008
Posts: 4
it worked
Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 439

What property type you set in action class?


Maki Jav

Help gets you when you need it!
I agree. Here's the link:
subject: Struts2 select default selection
It's not a secret anymore!