Hi Shawn
I know that according to the books I have to use
test1.my_StringA (with lowercase) but for some reasons it
does not work in my case.
So, in my class I have
filed my_StringA,
and
method getMy_StringA,
but when I execute my JSP with ${test1.my_StringA} ,
I got an error like:
javax.servlet.jsp.JspException:
An error occurred while evaluating custom action attribute "value" with
value "${test1.my_StringA}":
Unable to find a value for "my_StringA" in object of
class "A" using operator "."
The same JSP works OK with ${test1.My_StringA}.
I know that this is very funny, but why it works with uppercase, and
not with lowercase, as it should, I really don't know.
Regards
Marino Tudor
-----Original Message-----
From: Shawn Bayern [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 18, 2002 3:58 PM
To: Tag Libraries Users List
Subject: Re: nested forEach in JSTL, how?
You have the sense and structure of the loops correct; I believe that
you're just referring to properties with the wrong names. Without a
BeanInfo class, the method "getMy_StringA()" turns into the property
"my_StringA", not "My_StringA". (Note the initial lowercase character.)
It's more typical in Java not to include the "_", but this doesn't change
the way that JavaBean accessors are interpreted by the Introspector.
Thus, if you try the following instead, it should work:
<table>
<c:forEach var="test1" items="${X}">
<tr>
<td><c:out value="${test1.my_StringA}"/></td>
</tr>
<c:forEach var="test2" items="${test1[my_List]}">
<tr>
<td><c:out value="${test2.my_StringB}"/></td>
</tr>
</c:forEach>
</c:forEach>
</table>
--
Shawn Bayern
"JSTL in Action" http://www.jstlbook.com
(coming in July 2002 from Manning Publications)
On Thu, 18 Jul 2002, Marino Tudor wrote:
> I have class A and class B where
> class A hold a Collection of calss B in "My_List".
> ******************************************
> public class A {
> private String My_StringA;
> private java.util.List My_List;
>
> public void setMy_StringA(String param){
> this.My_StringA = param;
> }
> public String getMy_StringA(){
> return this.My_StringA;
> }
>
> public void setMy_List(java.util.List param){
> this.My_List = param;
> }
> public List getMy_List(){
> return this.My_List;
> }
> }
> ***************************
> public class B {
> private String My_StringB;
> public void setMy_StringB(String param){
> this.My_StringB = param;
> }
> public String getMy_StringB(){
> return this.My_StringB;
> }
> }
> ***********************************
>
> Let's say that I have a Collection of class A saved
> in request attribute called "X".
> (request.setAttribute("X", ... collection of classes A);
>
> How can I print out all My_StrigsB for every calss of A using JSTL forEach
?
>
> I tried something like this, but it didn't work:
>
> <table>
> <c:forEach var="test1" items="${X}">
> <tr>
> <td><c:out value="${test1.My_StringA}"/></td>
> </tr>
> <c:forEach var="test2" items="${test1[My_List]}">
> <tr>
> <td><c:out value="${test2.My_StringB}"/></td>
> </tr>
> </c:forEach>
> </c:forEach>
> </table>
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>