aspose file tools*
The moose likes Struts and the fly likes struts iterate tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts iterate tag " Watch "struts iterate tag " New topic
Author

struts iterate tag

li xiaohua
Greenhorn

Joined: Nov 04, 2002
Posts: 2
Hi,All
I set the 'loginForm' Object which contains the array of 'userForm' objects (userList) in request
when i want to use the Struts iterator tag to loop the list and print out property 'name',
i am getting following error.
<Error> <HTTP> <101017> <[ServletContext(id=5981 name=DefaultWebApp,context-path=)]
Root cause of ServletException
javax.servlet.jsp.JspException: Cannot find bean userForm in scope null
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:493)

Here is the code:
<logic:iterate id="loginForm" name="loginForm" scope="request" property="userList">
<tr >
<td>
<bean:write name="userForm" property="name" />
</td>

</tr>
</logic:iterate>
Can you explain me what went wrong?
Is it required for all of the'userForm' to be set in request/session too?
Any comments will be highly appreciated
thanks
Art choz
Greenhorn

Joined: Oct 11, 2002
Posts: 5
Hi,
I think that your error is in the "name" property of the write tag, it must be the name of the "id" tag of the iterate.
gool luck.
bye


Thanks.<br />Arturo Chozas<br />INFORMA S.A.
li xiaohua
Greenhorn

Joined: Nov 04, 2002
Posts: 2
problem fixed
thanks ,you are right
Tim Eyre
Greenhorn

Joined: May 20, 2002
Posts: 20
I have exactly the same problem, but my bean:write name attribute is pointing to my logic:iterate id attribute:
<logic:iterate id="rep" name="user" property="reports">
<tr>
<td align="left">
<bean:write name="rep" property="name" filter="true"/> </td>
<td align="left">
<bean:write name="rep" property="description" filter="true"/> </td>
</tr>
</logic:iterate>
My report bean is defined as follows:
public class Report {
String name = "REPBEAN";
String description = "Empty report bean";
Report(String name, String description) {
this.name = name;
this.description = description;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return this.description;
}
public String toString() {
return "Report: " + name + ", Description: " + description;
}
}
And my User bean is:
public class User implements Serializable {
private String username = null;
private Report[] reports = null;
User (String username) {
this.username = username;
}
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
public void setReports(Report[] reports) {
this.reports = reports;
}
public Report[] getReports() {
return this.reports;
}
}
And they get populated by the following code:
User u = new User("timmy");
Report r1 = new Report("this", "works");
Report r2 = new Report("this", "works too");
Report reps[] = new Report[2];
reps[0] = r1;
reps[1] = r2;
u.setReports(reps);
HttpSession session = request.getSession();
session.setAttribute("user", u);
Any ideas? I've tried every combination of the scope attribute, but I still get:
"Cannot find bean rep in scope ???"
Thanks for any help you can give.
Tim
[ November 26, 2002: Message edited by: Tim Eyre ]
 
 
subject: struts iterate tag
 
Similar Threads
how to solve No collection found.
Strange Struts error with logic iterate bean.
logic:iterate tag displaying same results??
No getter method for property name of bean userList
logic:iterate pls any body help me