struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexis Gallagher <alexis_gallag...@yahoo.com>
Subject Re: Newbie logic:iterator question
Date Thu, 17 Oct 2002 12:04:33 GMT
Hi Dave,

> I have no idea how or where I define the "user"
> object.  I can't 
> figure out where the Struts example application is
> defining this.

Define the user object using a <jsp:useBean ..> tag or
a struts <bean:define> tag. Personally, I've never
gotten <bean:define> to work so I've got loads of jsp
snippets like the following, which renders a table
listing the system's users:

	<jsp:useBean id="userListHelper" scope="request"
class="com.tpc.UserListHelper" />

	  <logic:iterate id="item" name="userListHelper"
property="userList" indexId="index">
    <td><bean:write name="item" property="username"
/></td>
...
</logic:iterate>

So this creates an instance of my javabean class
called com.tpc.UserListHelper. This class has a public
method getUserList() which returns a List object. It
then iterates through all those objects and calls
their getUsername() method, which returns a String.

Hope this helps,
Alexis 

--- Dave Hoover <dave@redsquirrel.com> wrote:
> I need to display an HTML table using Struts.  The
> table contents 
> are the results of a database query.  It seems that
> the <logic:iterate> 
> tag is the way to do what I want, but I just cannot
> seem to get the 
> thing to work.
> 
> I was just Googling for an answer and came across 
> "A Walking Tour of the Struts Example Application"
>
(http://struts.application-servers.com/struts-layout/tour.htm).
> In this Tour, it describes the following  iterate
> tag like this:
> 
>   <logic:iterate name="user"
> property="subscriptions" id="subscription">
>   <!-- block to repeat -->
>   </logic:iterate>
> 
>   The three parameters to the iterate tag ( name,
> property, and id)
>   tell it to
> 
>   1. Check this context for an attribute (e.g.
> object) named "user",
>   2. Snag the property of user named
> "subscriptions",  
>   3. In the block to iterate, use "subscription"
> (singular) as the
>   name for each member of the collection.
> 
> I have no idea how or where I define the "user"
> object.  I can't 
> figure out where the Struts example application is
> defining this.
> 
> 
> Also, the object that I want to iterate over is a
> Vector of HashMaps.
> Would I use nested iterate tags?  Is it possible to
> do what I'm 
> trying to do?  I need a bit of guidance, perhaps I'm
> making this 
> too difficult.
> 
> Thanks,
> Dave the Confused Newbie
> 
> 
> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:  
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@jakarta.apache.org>
> 


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

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


Mime
View raw message