OK I've overcame this problem by (reluctantly) using <% if (session.getAttribute("myAgentsVector") == null ) { %> ..... display static html .... <% } else { %> ..... logic:iterate thru the Vector and bean:write each element's properties into a table .... <% } %>
But I keep getting an error message "Cannot find bean agent in scope null" where the bean 'agent' is the id given in the logic:iterate tag. By default - this bean will have page scope, so by using the default bean:write tag - it should be located. Here's the key tags that are causing this: <logic:iterate id="agent" name="myAgentsVector" type="zeus.generator.web.model.object.Agent" scope="session"> .... <bean:write name="agent" property="name"/> .... </logic:iterate> Oh I hope I don't need to begin yet another new subject thread! : ( Cheers. Lindsay -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: 14 March 2002 16:18 To: [EMAIL PROTECTED] Subject: <logic:present> and <logic:notPresent> tags - both are being exec uted! Hi, I have an action class (HomeAction) that sets a session attribute (can I call this a bean!?) which is a java.util.Vector of my own custom Agent objects. This attribute is only set if the Vector, created by the action class, is not empty. Anyway - eventually the HomeAction class will forward to home.jsp which is where I want to present this Vector in a table. At present, this Vector is always empty and so the HomeAction class will NOT add it to the session. Before I continue - here is the troublesome JSP code: <logic:notPresent name="myAgentsVector" scope="session" type="java.util.Vector"> <% System.out.println("Did not find session attribute myAgentsVector. User has no agents"); %> <tr> <td width="3"> </td> <td> <div align="center">You currently have no agents.</div> </td> </tr> </logic:notPresent> <logic:present name="myAgentsVector" scope="session" type="java.util.Vector"> <% System.out.println("Found session attribute myAgentsVector. Creating dynamic My Agents table"); %> <!-- START "MY AGENTS" TABLE DYNAMIC CONTENT --> <logic:iterate id="agent" name="myAgentsVector" type="zeus.generator.web.model.object.Agent" scope="page"> <% System.out.println("Created a bean called agent - from myAgentsVector"); %> <tr> <td width="3" bgcolor="<bean:write name="agent" property="color"/>" bordercolor="#CCCCCC"> </td> <td><bean:write name="agent" property="name" scope="page"/></td> <td><bean:write name="agent" property="type.name" scope="page"/> (v<bean:write name="agent" property="type.version" scope="page"/>)</td> <td><bean:write name="agent" property="status" scope="page"/>/td> <td>To be defined (using Struts)</td> </tr> </logic:iterate> <!-- END "MY AGENTS" TABLE DYNAMIC CONTENT --> </logic:present> I'd expect only the body of the <logic:notPresent> tag to be executed, but for some reason the <logic:present> tag's body is also being executed. Here is the console output to show it: 2002-03-14 16:08:30 - Ctx(/struts-SACT) : Compiling: /home.jsp to home_13 Did not find session attribute myAgentsVector. User has no agents Found session attribute myAgentsVector. Creating dydnamic My Agents table Created a bean called agent - from myAgentsVector 2002-03-14 16:08:32 - Ctx(/struts-SACT) : Exception in R( /struts-SACT + /home.jsp + null) - javax.servlet.ServletException: Cannot find bean agent in scope null Do any of you wise people ( =oS ) have any idea what I'm doing wrong in this code. Many many thanks, Lindsay -- 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]>