You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Shoukat, Faisal" <fa...@northgate-is.com> on 2006/03/23 15:42:14 UTC

html:option on a nested collection

Hi Guys,

 

I have a formBean which has a collection of objects within it called Apps.
Each App object has several fields with one of these fields being a
collection or list of Strings.

 

ExampleFormBean properties are

 

String Name

String Class

String Student

List apps

 

Each app object looks like this

String first

String second

List actions.  --- This is a collection of Strings

 

I am trying to display the actions of the app object in a drop down list.
But am having a few problems with the option tag.

 

So far I have this:

<logic:iterate name="exampleformbean" property="apps" id="app">

 

<html:select property="action" >

               <logic:iterate id="act" name="app" property="actions"
indexId="index">

                     <html:option value="1"><bean:write
name="act"/></html:option>

 

                </logic:iterate>

         </html:select>

 

This code displays the drop down with the correct string values showing.
However where I have put one above as the option value I actually want to
put something like the actual String i.e: <bean:write name="act"/>.

 

Does anyone know how I can do this. I have tried html:options and
optionscollections but could not get them to work.

 

If the suggestion is to go with nested tags please provide an example as I
could not get far with this either.

 

Secondly, If I submit the form but have modified two rows from the drop down
when I get to the action class how can I know which rows I have modified.

 

Thanks in advance

 


Re: html:option on a nested collection

Posted by Vinit Sharma <vi...@gmail.com>.
You can use EL extention of html tag and use something like this:

<html:option value="${exampleFormBean.apps.actions.act}"><bean:write
name="act"/></html:option>

Assuming getters are defined for all properties.

Regds,


On 3/23/06, Shoukat, Faisal <fa...@northgate-is.com> wrote:
>
> Hi Guys,
>
>
>
> I have a formBean which has a collection of objects within it called Apps.
> Each App object has several fields with one of these fields being a
> collection or list of Strings.
>
>
>
> ExampleFormBean properties are
>
>
>
> String Name
>
> String Class
>
> String Student
>
> List apps
>
>
>
> Each app object looks like this
>
> String first
>
> String second
>
> List actions.  --- This is a collection of Strings
>
>
>
> I am trying to display the actions of the app object in a drop down list.
> But am having a few problems with the option tag.
>
>
>
> So far I have this:
>
> <logic:iterate name="exampleformbean" property="apps" id="app">
>
>
>
> <html:select property="action" >
>
>                <logic:iterate id="act" name="app" property="actions"
> indexId="index">
>
>                      <html:option value="1"><bean:write
> name="act"/></html:option>
>
>
>
>                 </logic:iterate>
>
>          </html:select>
>
>
>
> This code displays the drop down with the correct string values showing.
> However where I have put one above as the option value I actually want to
> put something like the actual String i.e: <bean:write name="act"/>.
>
>
>
> Does anyone know how I can do this. I have tried html:options and
> optionscollections but could not get them to work.
>
>
>
> If the suggestion is to go with nested tags please provide an example as I
> could not get far with this either.
>
>
>
> Secondly, If I submit the form but have modified two rows from the drop
> down
> when I get to the action class how can I know which rows I have modified.
>
>
>
> Thanks in advance
>
>
>
>
>


--
Vinit Sharma