| Author |
Help with an c:forEach and html:links
|
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
I am trying to iterate over an ArrayList of beans and build html:links accordingly with the correct parameters. Here is how I retrieve and build my ArrayList: Issues has a getter for ticket. And then in my JSP: The error I am getting when forwarded to the JSP is: So am I doing something wrong/stupid here or what? Any help is appreciated. Thanks. [ August 11, 2004: Message edited by: Gregg Bolinger ]
|
 |
Junilu Lacar
Bartender
Joined: Feb 26, 2001
Posts: 4118
|
|
try not using EL for paramName and paramProperty. paramName="item" paramProperty="ticket" Also, I wouldn't specify paramScope="request" unless you're sure that the bean "item" will be in the request context. [ August 11, 2004: Message edited by: Junilu Lacar ]
|
Junilu - [How to Ask Questions] [How to Answer Questions] [MiH]
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
Originally posted by Junilu Lacar: try not using EL for paramName and paramProperty. paramName="item" paramProperty="ticket" Also, I wouldn't specify paramScope="request" unless you're sure that the bean "item" will be in the request context. [ August 11, 2004: Message edited by: Junilu Lacar ]
That didn't work either. Now I get: Before, when I was using EL, it at least knew I was looking for an Issue object. But now it doesn't event know what item is it seems.
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
Ok, I think I know why it won't work. I just can't figure out a good way to make it work. Struts taglibs don't work with JSTL tags when EL is involved. Basically, the html:link tag I am using is looking for my Issue object in some scope rather than looking at the current item pulled by my forEach tag for the Issue object. Now, what can I do to make this work better? Should I be building list of Issues differently?
|
 |
Junilu Lacar
Bartender
Joined: Feb 26, 2001
Posts: 4118
|
|
Originally posted by Gregg Bolinger: Struts taglibs don't work with JSTL tags when EL is involved.
From the error messages, it seems to be working fine with EL: paramName="${item}" paramScope="request" gives you "Cannot find bean com.intrustbank.anykey.beans.dao.Issue@1d592a in scope request" Which indicates that "${item}" is being evaluated to item.toString() which evaluates to com.intrustbank.anykey.beans.dao.Issue@1d592a Of course, this is not the correct attribute key (there's no attribute "com.intrustbank.anykey.beans.dao.Issue@1d592a" in any context), so the tag won't find anything whereas using paramName="item" gives you the error "Cannot find bean item in scope request" Which means it's looking for the correct attribute key ("item"). This also tells me that you either left paramScope="request" in the tag or that the html:link tag fails when it can't find "item" after searching the request context. I believe the c:forEach will put the variable in the page Context, not the request context. If you really think it's a problem with the tag libraries and EL, make sure you are using the EL-aware struts-el.jar
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
This also tells me that you either left paramScope="request" in the tag All is well now. I would suspect that if I put paramScope="page" it would have worked as well since, as you said: I believe the c:forEach will put the variable in the page Context, not the request context. But I'm not going to worry about it since it is working now. Thanks a million.
|
 |
 |
|
|
subject: Help with an c:forEach and html:links
|
|
|