You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Doug Bryant <db...@scra.org> on 2003/04/14 19:40:59 UTC

accessing collections from bean:write

We have a collection (arrayList) in session that we need to read a
property of the first item in the collection.

I want to be able to say something like [0].group where [0] is the first
item in the collection in session and group is the property accessor

How do I do that?  Every time I try it or some other combination of it,
I get a "no getter method for [0].group" error.

Any ideas?

Thanks, Doug


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


Re: accessing collections from bean:write

Posted by Natalie D Rassmann <na...@lmco.com>.
I had this same problem....  You need to have a get method for property[int
index] OR if the ArrayList is of some object, you would iterate like
this....

<logic:present scope="session" name="USER_ACCOUNT">

        <logic:iterate id="userProfile"  name="USER_ACCOUNT" scope="session"
property="profile" type="promis.data.DTO.UserProfileDTO">

           <html:link page="/<bean:write name="userProfile"
property="projectName"/>.do">
              <bean:write name="userProfile" property="projectName"/>
           </html:link>

        </logic:iterate>

     </logic:present>

Where USER_ACCOUNT is a bean which contains a property which is an
ArrayList.  The property that is an ArrayList is profile.  I  want to
extract project name.  projectName is a property of the Bean which the
ArrayList is made of....

I hope this helps.

Doug Bryant wrote:

> We have a collection (arrayList) in session that we need to read a
> property of the first item in the collection.
>
> I want to be able to say something like [0].group where [0] is the first
> item in the collection in session and group is the property accessor
>
> How do I do that?  Every time I try it or some other combination of it,
> I get a "no getter method for [0].group" error.
>
> Any ideas?
>
> Thanks, Doug
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: accessing collections from bean:write

Posted by Doug Bryant <db...@scra.org>.
Thanks - I think we are going to have to break down and use jsp
scriptlets :(

Doug



On Mon, 2003-04-14 at 13:51, Jesse Vitrone wrote:
> I haven't found a good way to only get at the X item in a collection of
> things.  
> 
> In our case, it was a Person, who had a Collection of Addresses, so we just
> made a getFirstAddress() method on the Person.  That way in our jsp, we can
> say:
> 
> <bean:define id="address" 
>              name="person" 
>              property="firstAddress" 
>              type="com.mycompany.Address"/>
> 
> That only works if your collection is on another object though.  And it
> still doesn't seem like a great solution, but it was the only thing we
> found.
> 
> Jesse
> 
> -----Original Message-----
> From: Doug Bryant [mailto:dbryant@scra.org] 
> Sent: Monday, April 14, 2003 1:41 PM
> To: Struts Users Mailing List
> Subject: accessing collections from bean:write
> 
> 
> We have a collection (arrayList) in session that we need to read a property
> of the first item in the collection.
> 
> I want to be able to say something like [0].group where [0] is the first
> item in the collection in session and group is the property accessor
> 
> How do I do that?  Every time I try it or some other combination of it, I
> get a "no getter method for [0].group" error.
> 
> Any ideas?
> 
> Thanks, Doug
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
-- 
Doug Bryant
ICF Consulting
Software Engineer

phone: 843.760.3635
  fax: 843.207.5444
email:  wbryant@icfconsulting.com
        dbryant@scra.org


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


RE: accessing collections from bean:write

Posted by Jesse Vitrone <je...@vitalworks.com>.
I haven't found a good way to only get at the X item in a collection of
things.  

In our case, it was a Person, who had a Collection of Addresses, so we just
made a getFirstAddress() method on the Person.  That way in our jsp, we can
say:

<bean:define id="address" 
             name="person" 
             property="firstAddress" 
             type="com.mycompany.Address"/>

That only works if your collection is on another object though.  And it
still doesn't seem like a great solution, but it was the only thing we
found.

Jesse

-----Original Message-----
From: Doug Bryant [mailto:dbryant@scra.org] 
Sent: Monday, April 14, 2003 1:41 PM
To: Struts Users Mailing List
Subject: accessing collections from bean:write


We have a collection (arrayList) in session that we need to read a property
of the first item in the collection.

I want to be able to say something like [0].group where [0] is the first
item in the collection in session and group is the property accessor

How do I do that?  Every time I try it or some other combination of it, I
get a "no getter method for [0].group" error.

Any ideas?

Thanks, Doug


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


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