struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Todd Pierce <Todd.Pie...@hubbub.com.au>
Subject RE: How to user logic:iterate
Date Mon, 09 Sep 2002 23:41:24 GMT
Your arraylist isn't in the page context. Try this:

 <%
    ArrayList users = (ArrayList) request.getAttribute("users");
    pageContext.setAttribute("userList", users);
 %>

    <logic:iterate name="userList" id="aUser" scope="request">
    <tr>
      <td><bean:write name="aUser" property="user.userID"/></td>
...

or use the collection attribute instead of the name attribute in the iterate
tag, ike this:

 <%
    ArrayList users = (ArrayList) request.getAttribute("users");
 %>

    <logic:iterate collection="<%= users %>" id="aUser" scope="request">
    <tr>
      <td><bean:write name="aUser" property="user.userID"/></td>
...

-----Original Message-----
From: Michael Lee [mailto:mleejr@hotmail.com]
Sent: Tuesday, 10 September 2002 6:56 AM
To: Struts Users Mailing List
Subject: How to user logic:iterate


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

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