wood burning stoves 2.0*
The moose likes Struts and the fly likes show preselected values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "show preselected values" Watch "show preselected values" New topic
Author

show preselected values

ravi janap
Ranch Hand

Joined: Nov 04, 2000
Posts: 389
Hi All
How can I show preselected values in struts drop down list box when I bring up the JSP for the first time ?
Thanks in advance
Ravindra


SCJP, SCJD, SCWCD, SCBCD, SCEA
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 566
You have to set the properties of the formbean to the appropriate value during your action. Then in the JSP the corresponding option will be selected.
This means the JSP should be accessed first by an action, not by a direct call to the JSP. Set up an action mapping for it.
There is of course a quick and dirty work-around - you could just set the value of the property in the formbean with code in the declaration or the reset().
[ November 27, 2002: Message edited by: Adam Hardy ]

I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
ravi janap
Ranch Hand

Joined: Nov 04, 2000
Posts: 389
Hi Adam
The JSP is being accessed by a action and not being invoked directly. The properties in the form bean match the form field attribute name in JSP. I have been succesful in making one drop down value preselected using this solution. I am just wondering where I am going wrong ?
Thanks
Ravindra
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 566
Well, how are you initialising the formbean properties? This should be done in the formbean reset() method or alternatively on declaration of the property member variables, if they're fixed.
 
Don't get me started about those stupid light bulbs.
 
subject: show preselected values