ArrayList components = (ArrayList) service
                                     .gatherAccessory(Bean.getContainer());

session.setAttribute("someKey", components);

-or-
request.setAttribute("someKey", components);


<!-- jsp -->

<logic:iterate id="item" name="someKey" scope="session"> //or request scope
  <bean:write name="item" property="name" /><br />
</logic:iterate>

-Jacob

| -----Original Message-----
| From: Ray Madigan [mailto:[EMAIL PROTECTED]]
| Sent: Tuesday, February 11, 2003 12:06 AM
| To: Struts Users Mailing List
| Subject: Newbie Question
| 
| Greetings:
| 
| I am new to struts, and i have a question that has been giving me fits all
| day.
| 
| I have a large application I am attempting to rewrite in struts, with
| several hundred jsp's and servlets.  It currently runs on Tomcat.  I am
| using, don't all of you laugh at once, 1.1-b3.
| 
| I haveured out some of how struts works from reading the samples and
| groping
| throught the code, but i can't seem to figure out how to make
| logic:iterate
| work.  Here are a couple oc code fragments, if someone could point out
| where
| i'm a bonehead, i would appreciate it.
| 
| In the Action class:
|     ArrayList components = ( ArrayList ) service.gatherAccessory
|  Bean.getContainer ( ) );
|     // Error checking and logging etc
|     if ( components != null && components.size ( ) > 0 ) {
|         System.out.println ( "Nav: Comp: " + components.size ( ) );
|         //txSupport component = new txSupport ( );
|         //session.setAttribute ( Constants.COMPONENT_KEY, components.get
| ( 1 ) );
|         //session.setAttribute ( Constants.COMPONENTS_KEY,
| components.toArray ( as ) );
|         session.setAttribute ( component, components.get ( 0 ) );
|         navForm.setComponents ( components );
|     }
| 
| I have tried several alternatives as to how to set the id attribute:
| - an empty instance of the Bean that is contained in the collection
| - the first element in the array
| I have tried to set the name property of the iterate to an array
| all with different errors.  The one that worked the best was when
| I pointed the id property of iterate to the first element of the
| Collection.  Here i simply got the iterator to iterate the first
| element.  In the Action class I have iterated the Collection and
| there are three elements in the list.
| 
| In the jsp:
| 
|   <logic:iterate id="component" name="navigateForm" property="components"
| >
| 
|     <tr>
|       <td COLSPAN="2"align="left">
|         <bean:write name="component" property="support" filter="true"/>
|       </td>
|     </tr>
| 
|   </logic:iterate>
| 
| The navigateForm has a pair of methods get/setComponents that return the
| Collection.  If I put a logic:equal and test a member of the iteration it
| works in all cases.
| 
| I am very perplexed by this situation and any light shed on the problem
| would be appreciated.
| 
| Thanks in advance
| Ray Madigan
| 
| 
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: [EMAIL PROTECTED]
| For additional commands, e-mail: [EMAIL PROTECTED]


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

Reply via email to