struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton" <niall.pember...@blueyonder.co.uk>
Subject Re: A Select tag nested inside an iterate tag and Form that contains a String[] how do I do it?
Date Fri, 11 Jun 2004 00:37:19 GMT
Your iterate will store each element in your userIds[] as a page scope
variable with the name "foo". So the selects need to point to that.

However the <html:select> tag either needs to point to a bean's property
(rather than a String) or have its value attibute set. If you're using jstl
you could set the value attribute on the select to foo...

     <html:select property="userIds" indexed="true" value="${foo}">

otherwise I think your userIds should be a bunch of beans rather than
String[]

Niall


----- Original Message ----- 
From: "Mark Palmer" <bikerx1969@yahoo.com>
To: <user@struts.apache.org>
Sent: Friday, June 11, 2004 12:58 AM
Subject: A Select tag nested inside an iterate tag and Form that contains a
String[] how do I do it?


> I have a
>
> In my jsp I have a Form object which contains
>
> String[] userIds
>
> which is correctly populated with a list of userIds
>
> I want to display each of this in a list of select
> boxes (one select box for each element of String[]
> userId)
>
>
> I have the following code in my jsp
>
> <logic:iterate name="editClientForm"
> property="userIds" id="foo">
>   <tr><td>
>     <html:select property="userIds" indexed="true">
>       <html:options collection="users"
> property="userId" labelProperty="descr"/>
> </html:select>
> </td></tr>
> </logic:iterate>
>
> It displays a list of select boxes, but each select
> has all of the userIds select that are in String
> []userId array.
>
> i.e. it can get it to iterate over the collection but
> the value of <html:select property="userIds" should be
> current element of userId [] rather than the entire
> contents of user []
>
> This is the render HTML
>
> <select
> name="org.apache.struts.taglib.html.BEAN[0].userIds">
> <option value="xyz1" selected="selected">Bill
> joy</option>
> <option value="xyz2">Gates</option>
> <option value="xyz3" selected="selected">buck
> rogers</option>
> <option value="xyz4">Amy-yy Lee</option>
> </select>
>
> <select
> name="org.apache.struts.taglib.html.BEAN[1].userIds"><option
> value=""></option>
> <option value="xyz1" selected="selected">Bill
> joy</option>
> <option value="xyz2">Gates</option>
> <option value="xyz3" selected="selected">buck
> rogers</option>
> <option value="xyz4">Amy-yy Lee</option>
> </select>
>
> see how selected="selected" is on the first and third
> element on both lists.
>
> I only want the each list to have value selected.
>
> The problem that I having is getting access to the
> individual elements in an array.
>
> Any help much appreciated.
>
> This one driving me crazy
>
>
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Friends.  Fun.  Try the all-new Yahoo! Messenger.
> http://messenger.yahoo.com/
>
> ---------------------------------------------------------------------
> 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