petepalmer
asked on
Iterating a List with Struts
Hi,
I've finally got Struts to play nice and I've even gotten Hibernate to work to. Now I have a nice list of objects that I want to iterate over in a JSP page. I can do it with a scriptlet but I was hoping to use one of the taglibs. I've looked at <logic:iterate> but I'm not sure how to just pass it a List which is sitting in the request object. I really don't see the point in creating an object just to wrap around the List.... so am I missing something or is there a better way? :)
Thanks in advance! :)
I've finally got Struts to play nice and I've even gotten Hibernate to work to. Now I have a nice list of objects that I want to iterate over in a JSP page. I can do it with a scriptlet but I was hoping to use one of the taglibs. I've looked at <logic:iterate> but I'm not sure how to just pass it a List which is sitting in the request object. I really don't see the point in creating an object just to wrap around the List.... so am I missing something or is there a better way? :)
Thanks in advance! :)
Maybe useful: http://jguru.com/forums/view.jsp?EID=1223329
ASKER
He appears to be trying the same thing I am.
What it appears to want is the name of a bean and then the method to call to get the list. However I haven't got a bean with such a getter - I've just got a List object in the request scope which afaik doesn't have a method to return itself :)
What it appears to want is the name of a bean and then the method to call to get the list. However I haven't got a bean with such a getter - I've just got a List object in the request scope which afaik doesn't have a method to return itself :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I suppose hibernate gives you a collection of object
so something like this maybe work for you
<logic:iterate id="user" name="userlist">
Firstname: <bean:write name="user" property="firstname" /><br /> --> equivalent to say user.getFirstname()
Lastname: <bean:write name="user" property="lastname" /> --> equivalent to say user.getLastname()
</logic:iterate>
so something like this maybe work for you
<logic:iterate id="user" name="userlist">
Firstname: <bean:write name="user" property="firstname" /><br /> --> equivalent to say user.getFirstname()
Lastname: <bean:write name="user" property="lastname" /> --> equivalent to say user.getLastname()
</logic:iterate>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Well I solved this one by using arnon81's solution - but I'd already figured it out before that with help frm the info that zzynx gave.....
So I'm splitting the points on this one :)
So I'm splitting the points on this one :)
Thanks