Hi, In my JSP page I am using following code for displaying selst tag:- <html:select name="userForm1" value="active" > <html ption value="pending" >pending</html ption> <html ption value="active">active</html ption> <html ption value="blacklisted">blacklisted</html ption> <html ption value="cancel">cancel</html ption> <html ption value="denied">denied</html ption> </html:select>
Now according to this tag when JSP page gets loaded, by default the second option of html:select "active" should be selected(as I am specifying value attribute for html:select as "active"). But when I am loading my jsp page, At all the times I am seeing the first option "pending" as selected. Why it is happening? Also if I want to get second option displayed as selected, what should I do for that? Please help me. Thank you. Prashant
********Deserve Before You Desire********
Joined: Feb 15, 2005
The <html:select> tag gets its value from the property you specify. The tag you showed us:
<html:select name="userForm1" value="active" >
doesn't even specify a property attribute. Since a property attribute is required, I'm surprised the page even compiled at all. Or perhaps you didn't paste the full tag onto your post.
The way to pre-select one of the options is not to specify a value attribute, but to set the form bean property to the value of the option you want. The preferred place to do this would be in the Action class that forwards to this JSP. You could also do it in the JSP, like this: