Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

default selected value for html:select w/DynaActionForm

843836Aug 20 2004 — edited Feb 21 2007
Hi, all,

I am trying to find a way using struts to have a default selected value in an html select (drop down menu). I have found that with html:select, the name attribute should be pointed to a form bean in order to have that option selected.

However, after some research, I still do not understand how to make this work. I have form properties for the select menu, but not for the individual options? I am still not sure how to select a particular option. Perhaps mine is a special case because I amusing DynaValidatorActionForm, and thus the form bean is dynamic? Help please!

Here are snippets of my code:

form.jsp
<html:select property="securityLevelId">
   <html:option value="2">General User</html:option>
   <html:option value="3">Power User</html:option>
   <html:option value="4">Testing User</html:option>
   <html:option value="5">Admin User</html:option>
   <html:option value="6">Super User</html:option>
</html:select>
struts-config.xml
<form-bean name="userForm" type="org.apache.struts.validator.DynaValidatorActionForm">
   ...
   <form-property name="securityLevelId" type="java.lang.String" />
   ...
</form-bean>
Thanks!!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 21 2007
Added on Aug 20 2004
10 comments
639 views