You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Galbreath, Mark" <Ga...@tessco.com> on 2002/10/08 12:13:00 UTC

RE: Help with displaying contents of a List contained within a be an

Hey Wendy,

I'm not following you entirely here.  It looks to me like the output of
getPreferredAddress() is exactly what you want.  In any event, if
preferredAddress is actually another list (inside your resView list?), then
just define a page-scoped bean using the bean wrapper as the base.  In other
words, if you have a list (addressList) inside a bean (PersonInfoBean):

<bean:define name="PersonalInfoBean"
             property="data"
             type="com.myCompnay.PersonalInfoBean"
             id="personalInfo" />

<bean:define name="personalInfo"
             property="addressList"
             type="java.util.List"
             id="address" />

You can now iterate through the addresses contained within the bean using
the iterate tag with a name of "address."

Mark

-----Original Message-----
From: Wendy Smoak [mailto:Wendy.Smoak@asu.edu]
Sent: Monday, October 07, 2002 7:27 PM
To: 'Struts Users Mailing List'
Subject: Help with displaying contents of a List contained within a bean



I'm plodding along, coding Value Objects and DAO stuff.  I've got a
ResolutionView object, which contains a Person, Address, etc.  I have this:

<table border="1" width="50%">
<logic:iterate id="resView" name="foundPersons" >
  <tr>
    <td align="left">
      <bean:write name="resView" property="key" filter="true"/>
    </td>
    <td align="left">
      <bean:write name="resView" property="preferredName" filter="true"/>
    </td>
     <td align="left">
      <bean:write name="resView" property="preferredAddress" filter="true"/>
    </td>
  </tr>
</logic:iterate>
</table>

The only problem is that resView.getPreferredAddress() actually returns a
List, so the above bean:write tag produces something like: [123 State
Street, Phoenix AZ 12345] which is produced by the toString() method of the
List.

How do I work with the List instead of using bean:write?  I know how to do
it in Java, getting the iterator and iterating to get each value, which in
this case is a line of the address.  Do I need another logic:iterate tag?
(But the "bean" I need isn't in scope, it's inside the current resView
bean!).  An example would be appreciated-- I'm stuck.

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University PA Information Resources Management

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>