Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

show preselected values

 
ravi janap
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Adam Hardy
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
ravi janap
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic