Discussion:
How to user logic:iterate
Todd Pierce
2002-09-09 23:41:24 UTC
Permalink
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:***@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
Michael Lee
2002-09-10 01:12:31 UTC
Permalink
Thanks but this still isnt working!
Nothing I try works!
WTF! AAAAAAAAAAA
Help anyone? This can not be so uncommon as no one here knows how to do
this?

**ERROR**
<Sep 9, 2002 8:48:10 PM EDT> <Error> <HTTP>
<[WebAppServletContext(4298512,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:1534)


Here's one of the many errors.
Users object contains getUsers() that returns an ArrayList of User value
objects.

I've tried many combinations of these lines
<logic:iterate collection="<%= users.getUsers() %>" id="aUser"
name="users" scope="request">
<logic:iterate id="aUser" name="users" scope="request">
<logic:iterate id="aUser" name="users" property="users"
scope="request">

with these combinations of bean writers
<td><bean:write name="aUser" property="users.userID"/></td>
<td><bean:write name="aUser" property="userID"/></td>
<td><bean:write name="aUser" property="users.userID"
scope="request"/></td>
<td><bean:write name="aUser" property="userID"
scope="request"/></td>

But if I explicitly go through the object I can iterate through it. It seems
as though this tag needs better documentation and real world examples.
This works
<% Users users =

(Users)request.getAttribute("users");
if(users != null)
{
Iterator iterator = users.getUsers().iterator();
while(iterator.hasNext())
{%><tr><%
User user = (User)iterator.next();
out.print("<td>"+user.getUserID()+"</td>");
out.print("<td>"+user.getUserType()+"</td>");
out.print("<td>"+user.getFirstName()+"</td>");
out.print("<td>"+user.getMiddleName()+"</td>");
out.print("<td>"+user.getLastName()+"</td>");


out.print("<td>"+user.getAccountDisabled()+"</td>");
out.print("<td>"+user.getEmail()+"</td></tr>");
}
%>
<%}%>

Code is attached.
Help! I'm doing everything I can see/think of in the docs/examples/etc and
nothing is working.
Mike


----- Original Message -----
From: "Todd Pierce" <***@hubbub.com.au>
To: "Struts Users Mailing List" <struts-***@jakarta.apache.org>
Sent: Monday, September 09, 2002 7:41 PM
Subject: RE: How to user logic:iterate
Post by Todd Pierce
<%
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
<%
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-----
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)
Post by Todd Pierce
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
--
<mailto:struts-user-***@jakarta.apache.org>
Aaron Oathout
2002-09-10 02:29:09 UTC
Permalink
Hi Michael,

I'm not sure if you're using 1.1 or 1.0, but if you're using 1.1, why not
create a DynaActionForm to hold the "users" collection? I currently do the
same kind of task as you and the logic:iterate tag works great(tested
with just about every nightly build from 1.1b2 till today). Here is my
following configuration:

struts-config.xml

my form bean is defined as follows:

<form-bean name="users"
type="org.apache.struts.action.DynaActionForm">
<form-property name="count" type="java.lang.String" />
<form-property name="users" type="java.util.List" />
</form-bean>

My action is defined as follows:
<action path="/showUsers"
type="org.ifmc.struts.action.AdminAction"
name="users"
scope="request"
parameter="method"
validate="false">
<forward name="continue" path="template.users.layout" />
</action>

The snip of jsp that does the iteration is as follows:
<logic:iterate id="user" indexId="count" name="users" property="users">
<row:row evenStyleClass="evenrow" oddStyleClass="oddrow">
<td>
<%=count.intValue()+1%>.&nbsp;
<bean:write name="user" property="username" />
</td>
<td>
<bean:write name="user" property="email"/>
</td>
</row:row>
</logic:iterate>


As long as every request maps to an Action so no jsp's are exposed without
being processed through an Action first then all your form beans are populated before
the jsp get rendered. Why not try this approach instead of putting the
collection directly in request scope? Since every Action can have an
ActionForm tied to it if specified, you are guaranteed to have your
collection as long as you populate it. Just my .02


Aaron
Post by Michael Lee
Thanks but this still isnt working!
Nothing I try works!
WTF! AAAAAAAAAAA
Help anyone? This can not be so uncommon as no one here knows how to do
this?
**ERROR**
<Sep 9, 2002 8:48:10 PM EDT> <Error> <HTTP>
<[WebAppServletContext(4298512,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:1534)
Here's one of the many errors.
Users object contains getUsers() that returns an ArrayList of User value
objects.
I've tried many combinations of these lines
<logic:iterate collection="<%= users.getUsers() %>" id="aUser"
name="users" scope="request">
<logic:iterate id="aUser" name="users" scope="request">
<logic:iterate id="aUser" name="users" property="users"
scope="request">
with these combinations of bean writers
<td><bean:write name="aUser" property="users.userID"/></td>
<td><bean:write name="aUser" property="userID"/></td>
<td><bean:write name="aUser" property="users.userID"
scope="request"/></td>
<td><bean:write name="aUser" property="userID"
scope="request"/></td>
But if I explicitly go through the object I can iterate through it. It seems
as though this tag needs better documentation and real world examples.
This works
<% Users users =
(Users)request.getAttribute("users");
if(users != null)
{
Iterator iterator = users.getUsers().iterator();
while(iterator.hasNext())
{%><tr><%
User user = (User)iterator.next();
out.print("<td>"+user.getUserID()+"</td>");
out.print("<td>"+user.getUserType()+"</td>");
out.print("<td>"+user.getFirstName()+"</td>");
out.print("<td>"+user.getMiddleName()+"</td>");
out.print("<td>"+user.getLastName()+"</td>");
out.print("<td>"+user.getAccountDisabled()+"</td>");
out.print("<td>"+user.getEmail()+"</td></tr>");
}
%>
<%}%>
Code is attached.
Help! I'm doing everything I can see/think of in the docs/examples/etc and
nothing is working.
Mike
----- Original Message -----
Sent: Monday, September 09, 2002 7:41 PM
Subject: RE: How to user logic:iterate
Post by Todd Pierce
<%
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
Post by Todd Pierce
<%
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-----
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)
Post by Todd Pierce
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
--
Keven
2002-09-10 02:40:52 UTC
Permalink
Hi, all:

I want to use logic:present to check if user has logon.

If I use <% if(request.getSession().getAttribute(User) != null) { %> .....
it works fine. but I change it to use logic:present. I changed it to
<logic:present name="User" scope="session">... </logic:present>. But it
never evaluate <logic:present...> as true. Am I doing somethig wrong here?
How to use logic:present.Could some one give me an example?

Thanks,

Keven

______________________________________________________________________
Post your ad for free now! http://personals.yahoo.ca
Adrian Brown
2002-09-10 03:56:36 UTC
Permalink
Hi Keven,

A trick for young players is that you may not have put
in the line for the logic tags at the top of your jsp.
Check you have this:


<%@ taglib uri="/WEB-INF/struts-logic.tld"
prefix="logic" %>

If you do in fact have this, and you have the ability
to set break points in your Struts code, I'd put one
in the PresentTag.condition(boolean) method and see if
it is getting hit, and whether it is evaluating
properly.

Also make sure that your String User does actually
equal "user" if you intend to look it up in the
session.

That's all I can think of.

Adrian
Post by Keven
I want to use logic:present to check if user has
logon.
If I use <%
if(request.getSession().getAttribute(User) != null)
{ %> .....
it works fine. but I change it to use logic:present.
I changed it to
<logic:present name="User" scope="session">...
</logic:present>. But it
never evaluate <logic:present...> as true. Am I
doing somethig wrong here?
How to use logic:present.Could some one give me an
example?
Thanks,
Keven
______________________________________________________________________
Post by Keven
Post your ad for free now! http://personals.yahoo.ca
--
http://mobile.yahoo.com.au - Yahoo! Messenger for SMS
- Now send & receive IMs on your mobile via SMS
John Yu
2002-09-10 02:20:43 UTC
Permalink
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.
Post by Todd Pierce
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: ***@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.
Michael Lee
2002-09-10 14:40:39 UTC
Permalink
I would like to thank everyone on this email list that helped out. Every
little bit helped including the property attribute on iterate and that
logic:present is very handy.
The main problem though was a complete brain fart on my part.
I am moron, hear me roar.
I forgot to include the tag lib import for logic. The thing I dont
understand is how it even go to the bean:write tag inside the iterate and
failed there?
Oh well, if you ever get an error message like I did, don't run around like
a chickend with your head chopped off, just include this line at the top of
the jsp...
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

AAAAAAAAAAA, I hate stupid mistakes that waste everyone's time!!!
Mike
:(


----- Original Message -----
From: "John Yu" <***@scioworks.com>
To: "Struts Users Mailing List" <struts-***@jakarta.apache.org>
Sent: Monday, September 09, 2002 10:20 PM
Subject: Re: How to user logic:iterate
Post by John Yu
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>
Use your existing code, but get rid of the "user." part from the property
of the <bean:write> tags.
Post by Todd Pierce
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>
Post by John Yu
Post by Todd Pierce
<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)
Post by John Yu
Post by Todd Pierce
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
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.
--
<mailto:struts-user-***@jakarta.apache.org>
Ted Husted
2002-09-10 14:59:10 UTC
Permalink
Without the taglib statement, the tag is completely ignored, as if it
wasn't there. The JSP service assumes it's a HTML tag, and the browsers
silently swallow anything they don't understand. C'est la vive.

-T.
Post by Michael Lee
I would like to thank everyone on this email list that helped out. Every
little bit helped including the property attribute on iterate and that
logic:present is very handy.
The main problem though was a complete brain fart on my part.
I am moron, hear me roar.
I forgot to include the tag lib import for logic. The thing I dont
understand is how it even go to the bean:write tag inside the iterate and
failed there?
Oh well, if you ever get an error message like I did, don't run around like
a chickend with your head chopped off, just include this line at the top of
the jsp...
AAAAAAAAAAA, I hate stupid mistakes that waste everyone's time!!!
Mike
:(
----- Original Message -----
Sent: Monday, September 09, 2002 10:20 PM
Subject: Re: How to user logic:iterate
Post by John Yu
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>
Use your existing code, but get rid of the "user." part from the property
of the <bean:write> tags.
Post by Todd Pierce
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>
Post by John Yu
Post by Todd Pierce
<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)
Post by John Yu
Post by Todd Pierce
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
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.
--
--
--
Ted Husted, Husted dot Com, Fairport NY US
co-author, Java Web Development with Struts
Order it today:
<http://husted.com/struts/book.html>
Joe Barefoot
2002-09-10 17:49:09 UTC
Permalink
wow, really!? The JSP compiler doesn't even issue a warning? That's pretty lame.

--joe
Post by Todd Pierce
-----Original Message-----
Sent: Tuesday, September 10, 2002 7:59 AM
To: Struts Users Mailing List
Subject: Re: How to user logic:iterate[MORON]
Without the taglib statement, the tag is completely ignored, as if it
wasn't there. The JSP service assumes it's a HTML tag, and
the browsers
silently swallow anything they don't understand. C'est la vive.
-T.
Post by Michael Lee
I would like to thank everyone on this email list that
helped out. Every
Post by Michael Lee
little bit helped including the property attribute on
iterate and that
Post by Michael Lee
logic:present is very handy.
The main problem though was a complete brain fart on my part.
I am moron, hear me roar.
I forgot to include the tag lib import for logic. The thing I dont
understand is how it even go to the bean:write tag inside
the iterate and
Post by Michael Lee
failed there?
Oh well, if you ever get an error message like I did, don't
run around like
Post by Michael Lee
a chickend with your head chopped off, just include this
line at the top of
Post by Michael Lee
the jsp...
AAAAAAAAAAA, I hate stupid mistakes that waste everyone's time!!!
Mike
:(
----- Original Message -----
Sent: Monday, September 09, 2002 10:20 PM
Subject: Re: How to user logic:iterate
Post by John Yu
In Action,
request.setAttribute("myUsers", users); // no need to
call getUsers()
Post by Michael Lee
Post by John Yu
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>
Post by Michael Lee
Post by John Yu
<td><bean:write name="aUser" property="email"/></td>
</tr>
</logic:iterate>
</logic:present>
Use your existing code, but get rid of the "user." part
from the property
Post by Michael Lee
Post by John Yu
of the <bean:write> tags.
Post by Todd Pierce
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>
Post by John Yu
Post by Todd Pierce
<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
Post by Michael Lee
Post by John Yu
Post by Todd Pierce
at
org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:493)
Post by John Yu
Post by Todd Pierce
at
org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.
java:179)
Post by Michael Lee
Post by John Yu
Post by Todd Pierce
at
jsp_servlet.__advanced_user_search._jspService(__advanced_u
ser_search
Post by Michael Lee
Post by John Yu
Post by Todd Pierce
.java:1541)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ser
vletStubIm
Post by Michael Lee
Post by John Yu
Post by Todd Pierce
pl.java:265)
what am I doing wrong?
help!
thanks,
Mike
--
John Yu Scioworks Technologies
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.
Post by Michael Lee
Post by John Yu
--
--
--
Ted Husted, Husted dot Com, Fairport NY US
co-author, Java Web Development with Struts
Order it today:
<http://husted.com/struts/book.html>


--
To unsubscribe, e-mail: <mailto:struts-user-***@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-***@jakarta.apache.org>
Craig R. McClanahan
2002-09-10 18:33:56 UTC
Permalink
Date: Tue, 10 Sep 2002 10:49:09 -0700
Subject: RE: How to user logic:iterate[MORON]
wow, really!? The JSP compiler doesn't even issue a warning? That's pretty lame.
In the absence of a taglib directive, what looks to you like a Struts tag
just looks like template text to the compiler, and it is simply passed
through to the response (like all the non-tag HTML markup in a typical
Struts-based JSP page).

Remember, there is no requirement that the template text look like HTML or
XML markup, so there is absolutely no basis on which the compiler can
possibly consider this to be an error condition.
--joe
Craig
Keven
2002-09-10 20:17:19 UTC
Permalink
<% if(request.getSession().getAttribute(User) != null) { %> is same as
<logic:present name="User" scope="session">, is it right? If it is right,
why the former works, but the latter does not.(I have the line <%@ taglib
uri="/WEB-INF/struts-logic.tld" prefix="logic" %> in my jsp file).

Cn someone give me an example on how to use logic:present? I searched from
web, I can't find a specific example including the usage of logic:present.

Thanks,

Keven
Post by Michael Lee
Sent: Monday, September 09, 2002 7:41 PM
To: Struts Users Mailing List
Subject: How to use logic:present
I want to use logic:present to check if user has logon.
If I use <% if(request.getSession().getAttribute(User) !=
null) { %> .....
it works fine. but I change it to use logic:present. I changed it to
<logic:present name="User" scope="session">...
</logic:present>. But it
never evaluate <logic:present...> as true. Am I doing
somethig wrong here?
How to use logic:present.Could some one give me an example?
Thanks,
Keven
______________________________________________________________
________
Post your ad for free now! http://personals.yahoo.ca
--
______________________________________________________________________
Post your ad for free now! http://personals.yahoo.ca

Continue reading on narkive:
Loading...