It gets it from a JavaBean, List or Map either already in some reachable
scope or defined in your JSP.  For example, if I've defined a list of states
in an action class like:


List statesList = new ArrayList( State.getStates());

where State is a command object or stateless session bean querying the
database to retrieve a list of states, and I stick them into application
scope (so everyone can use it):

ServletContext servletContext = this.servlet.getServletContext();
servletContext.setAttribute( "listStates", listStates);

I can iterate through this list on a JSP and display the names like:

<table>
<logic:iterate name="listStates"  // the List
               property="state"   // a state object
               id="states"        // arbitrary page-scope name
               scope="application"
               type="com.whatever.State">
    <tr><td>
        <bean:write name="states" property="name" />
    </td></tr>
</logic:iterate>
</table>

or perhaps I need a data object specific to the user on the JSP:

<bean:define name="customer"
             property="data"
             type="com.whatever.Customer"
             id="orders"
             scope="session" />

where "customer" is an Order object specific to this customer's ID
(retrieved from the database when the user passes his ID through a form), so
I can display the pending orders this customer has placed:

<table>
<logic:iterate name="orders"
               property="customerOrders"
               id="order"
               type="com.whatever.CustomerOrder">
    <tr><td>
        <bean:write name="order" property="pending" />
    </td></tr>
</logic:iterate>
</table>


There are tons of examples in the archive.

Mark

-----Original Message-----
From: Struts Newsgroup [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 24, 2002 4:10 PM

Subject: Re: Best Practice Question/Conceptual Problem
From: "Kenny Smith" <[EMAIL PROTECTED]>
 ===
Hi Keith,

But how does the logic:iterate tag know where to get the information from?
That's the part that is really baffling me. I don't understand how it's
getting the information, so I'm not sure how to apply it to other
applications, etc. Could you (or anyone) please explain how it knows?

Kenny




--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to