Problems in iterating list using JSTL

Hi all,

Iam using jstl to iterate a list object using <c:forEach/>.The List contains a parent table values and set object containing the child table values.

the code snippet:

<c:forEach var="users" items="${userlist}">

<td align="left" valign="top">users.username</td>

<td align="left" valign="top">users.getchild.email</td>

</c:forEach>

getchild is a set object which contains email,firstname,lastname.

The error which i get is:

javax.servlet.ServletException: An error occurredwhile evaluating custom action attribute"value" with value"${users.getChild.email}": Unable to find a valuefor"email" in object ofclass"org.hibernate.collection.PersistentSet" using operator"." (null)

Hope you people got my problem.How to solve this.

Regards,

Karthik

Message was edited by:

KarthikM

[1329 byte] By [KarthikMa] at [2007-11-27 5:29:27]
# 1

Your original code looks a little funny

I don't see any tags with a "value" attribute, and no ${ } signs for EL expressions.

Obviously the code you have posted is not the source of the error you are getting.

Anyway the error is simple enough to explain.

It fails while evaluating: ${users.getChild.email}

It evaluates ${users.getChild} to an object of type org.hibernate.collection.PersistentSet. A set of some sort I guess.

EL doesn't deal well with sets, so it fails on calling getEmail() on this object. It can't find the attribute "email"

Why is it a set?

What is the class of the object represented by users?

Does it have a method called getGetchild() ? (thats what ${users.getchild} would look for)

What does that method return? As stated above the error indicates it is a set. Maybe it should be a List or Map?

evnafetsa at 2007-7-12 14:52:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...