wood burning stoves 2.0*
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 select default selection" Watch "Struts2 select default selection" New topic
Author

Struts2 select default selection

rohant paralikar
Greenhorn

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,
-Rohant
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.


Merrill
Consultant, Sima Solutions
rohant paralikar
Greenhorn

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

Joined: May 09, 2002
Posts: 435
Hi,

What property type you set in action class?


Thanks,

Maki Jav


Help gets you when you need it!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Struts2 select default selection
 
Similar Threads
Spring + struts2 DI problem
Struts2 nested iterators with listboxes
struts2 problem
Pagination in Struts2