Link to home
Start Free TrialLog in
Avatar of petepalmer
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! :)
Avatar of zzynx
zzynx
Flag of Belgium image

Avatar of petepalmer
petepalmer

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

ASKER CERTIFIED SOLUTION
Avatar of zzynx
zzynx
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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>
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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 :)
Thanks