| Author |
Cannot find bean in any scope...
|
Jibitesh Prasad
Greenhorn
Joined: Feb 20, 2007
Posts: 20
|
|
I have a action class which adds an arraylist of Friends object to the request. The action class is invoked from a hyperlink so it doesn't need a form element. Now when i am trying to display the contents of the bean, it gives an error saying
The jsp page reads....
<logic:iterate name="user_friends" id="friend" scope="request"> <tr> <td> <bean:write name="friend" property="first_name" /> </td> <td> <bean:write name="friend" property="last_name" /> </td> </tr> </logic:iterate>
The form-bean entry in struts-config.xml file reads: Can anyone help me with this?
|
 |
Ranjit Gopinathan
Ranch Hand
Joined: Jul 03, 2007
Posts: 46
|
|
Try <logic:iterate name="LoginForm" property="user_friends" id="friend"> .. <bean:write name="friend" property="first_name" /> ... </logic:iterate> if logic:iterate Name - is the name of form bean you are declaring in struts-config property - is the collection object you need to iterate id - the id you are giving for collection object to be iterated and when using bean:write name = id you declared in logic:iterate property = the variable inside the object from the collection you are iterating. eg: List friends contains list of objects of type friend. So when iterating friends you will get a friend object which will have "first name" variable , with getter/setter methods. HTH
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
|
Show us the action class that forwards to this JSP.
|
Merrill
Consultant, Sima Solutions
|
 |
Jibitesh Prasad
Greenhorn
Joined: Feb 20, 2007
Posts: 20
|
|
Thats my action class And it is being called from this page
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
|
The action looks OK. Did you remember to include a <%@ taglib> declaration for the logic tag library in your JSP? If you didn't, that would cause this problem.
|
 |
Jibitesh Prasad
Greenhorn
Joined: Feb 20, 2007
Posts: 20
|
|
|
Ranjit your method is not working....
|
 |
Jibitesh Prasad
Greenhorn
Joined: Feb 20, 2007
Posts: 20
|
|
Yupsie Merylll.. thanks a lot... got the prob [ ]
|
 |
 |
|
|
subject: Cannot find bean in any scope...
|
|
|