Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Re: html:select 1.2.9

Laurie Harper

2007-01-27

Replies:

Justin Chin wrote:
> I am trying to maintain which item was selected in a html:select
> dropdown that is not "multiple" after the validation occurs in the Form
> and I need to return to the jsp because something was missing. Here is
> my code snippet from my jsp:
>
>     <logic:iterate id="workitem" name="manager" indexId="index"
> property="workitems" type="com.my.app.WorkItem">
>         <tr>
>             <td>            
>                 <html:select property="action" size="1"
> indexed="true" >
>                     <html:options name="workitem"
> property="actions"/>
>                 </html:select>
>             </td>
>         </tr>
>     </logic:iterate>
>
> My Form reset method is empty:
>
>   public void reset(ActionMapping mapping, HttpServletRequest request)
> {
>         //DO Nothing
>   }
>
> When the app returns to the jsp on validation error from the Form, the
> selected item in the list is the first item (which is the default), and
> not the one that was selected. Why is the list being reset? Why
> doesn't it keep the selected item in the list when returning from the
> Form? How do I maintain the selected item in the list?

Assuming 'action' is the name of a property on your form bean, and that
you have both getAction and setAction defined, that looks reasonable. If
validation passes, do you see the correct value in the 'action' property?

Post the relevant parts of your struts-config.xml and form bean code if
you still need help resolving this.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.