struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kies <danielk...@gmail.com>
Subject Re: Validation Post-Back help
Date Fri, 31 Dec 2004 00:09:33 GMT
1) In my action class I put a list (statusList) into the request.
2) In the associated JSP, I read through the bean (statusList) and
display the data in a drop down box (the way you suggested):

<html:select property="statusType"> 
<html:options collection="statusList" property="statusType"/>
</html:select> 

3) When I go to validate(with the framework), and fail, I get Posted
back to the inputting .jsp, but when I do, my List, statusList, is no
longer there.  Is there a way I can configure the call so that it
keeps it in the request?  Do I have to add it again to the request in
the jsp?

My struts config has the statusList in the form used typed by a List.

I have the feeling I am just mossing something simple here to get the
data back in the request.
Thanks.




On Thu, 30 Dec 2004 14:00:30 -0700, Wendy Smoak <java@wendysmoak.com> wrote:
> From: "Daniel Kies" <danielkies@gmail.com>
> > in JSP to show the list in a drop down:
> > <select name="status">
> > <logic:iterate indexId="id" id="statusList" name="statusList">
> >         <option value="<bean:write name="statusList"
> > property="statusType"/>"><bean:write name="statusList"
> > property="statusType" /></option>
> > </logic:iterate>
> > </select>
> 
> Why are you not using the <html:select> and <html:options> (or
> <html:optionsCollections>)  tags?  You don't have to iterate over the
> collection, the framework will do it for you.
> 
> Example:
> <html-el:select property="type">
>    <html-el:options collection="contactTypes" property="key"
> labelProperty="value"/>
> </html-el:select>
> (contactTypes is a Map sitting in Application scope, but it'll work with
> other Collections in other scopes.)
> 
> Is your problem is that you are setting the values back into the form but
> they are not getting 'pre-selected' by Struts?  (You need to use the Struts
> tags for that to happen.)
> 
> Or is your question _how_ to set the values in the dynamic form bean?
> Should be...
> ( (DynaActionForm) form ).set( "fieldName", myList );
> 
> Post some of the code that's giving you trouble so we can see what you're
> doing instead of guessing.
> 
> --
> Wendy Smoak
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message