You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Justin Chin <jc...@nyc.saic.com> on 2007/01/22 17:10:11 UTC

html:select 1.2.9

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?

 

Thanks in advance for the help.

 

Regards,

Justin

 

 


Re: html:select 1.2.9

Posted by Laurie Harper <la...@holoweb.net>.
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@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org