struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Yu <j...@scioworks.com>
Subject Re: How to user logic:iterate
Date Tue, 10 Sep 2002 02:20:43 GMT
Option 1:

In Action,

   request.setAttribute("myUsers", users); // no need to call getUsers()

In JSP,

   <logic:present name="myUsers">
     <logic:iterate id="aUser" name="myUsers" property="users"
                    scope="request">
     <tr>
       <td><bean:write name="aUser" property="userID"/></td>
       <td><bean:write name="aUser" property="userType"/></td>
       <td><bean:write name="aUser" property="fName"/></td>
       <td><bean:write name="aUser" property="mName"/></td>
       <td><bean:write name="aUser" property="lName"/></td>
       <td><bean:write name="aUser" property="accoundDisabled"/></td>
       <td><bean:write name="aUser" property="email"/></td>
     </tr>
     </logic:iterate>
   </logic:present>

Option 2:

Use your existing code, but get rid of the "user." part from the property 
of the <bean:write> tags.

At 04:55 am 10-09-2002, you wrote:
>Im having a helluva time getting logic:iterate to work..
>I have a Users object that contains an array list of
>User objects.
>you call Users.getUsers() and it returns an arrayList
>I stick that in the request object in the perform() method using 
>request.setAttribute("users", users.getUsers());
>In the JSP the code I have is;
>
>  <% ArrayList users = (ArrayList) request.getAttribute("users");
>        if(users != null)
>        {%>
>     <logic:iterate name="users" id="aUser" scope="request">
>     <tr>
>       <td><bean:write name="aUser" property="user.userID"/></td>
>       <td><bean:write name="aUser" property="user.userType"/></td>
>       <td><bean:write name="aUser" property="user.fName"/></td>
>       <td><bean:write name="aUser" property="user.mName"/></td>
>       <td><bean:write name="aUser" property="user.lName"/></td>
>       <td><bean:write name="aUser" property="user.accoundDisabled"/></td>
>       <td><bean:write name="aUser" property="user.email"/></td>
>     </tr>
>     </logic:iterate>
>         <%}%>
>
>The error I'm getting is;
>
><Sep 9, 2002 4:52:00 PM EDT> <Error> <HTTP> 
><[WebAppServletContext(4398493,recei
>ptsplus,/receiptsplus)] Root cause of ServletException
>javax.servlet.jsp.JspException: Cannot find bean aUser in scope null
>         at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:493)
>         at 
> org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:179)
>         at 
> jsp_servlet.__advanced_user_search._jspService(__advanced_user_search
>.java:1541)
>         at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
>         at 
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
>pl.java:265)
>
>what am I doing wrong?
>help!
>thanks,
>Mike

-- 
John Yu                       Scioworks Technologies
e: john@scioworks.com         w: +(65) 873 5989
w: http://www.scioworks.com   m: +(65) 9782 9610

Scioworks Camino - "Don't develop Struts Apps without it!"
Copyright (c) 2002 John Yu/Scioworks Technologies. All rights reserved.


--
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