struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <>
Subject RE: [SPAM] - Re: Using the iterator to list results from a hibernate join - Email has different SMTP TO: and MIME TO: fields in the email addresses
Date Tue, 22 Jul 2008 16:46:02 GMT
--- On Tue, 7/22/08, Brian Daddino wrote:
> Instead of making my join in the query, I am just querying
> out my contacts and using 2 iterators...
> <s:iterator value="contacts" status="status">
>   <s:iterator value="contactmethodses" status="status">
>     <s:property value="firstName"/>
>     <s:property value="lastName"/>
>     <s:property value="method"/>
> ...
> This works fairly well, but loses my outer join (if there
> is no contact method, the contact's name is not even displayed).
> Am I missing something still?

Most likely :)

First of all, you're iterating over two sets of things: contacts, and contact methods.

The iterator tag [1] works by pushing each object of iteration onto the top of the stack.
The property tag [2] will call the getter on the object on the top of the stack (actually,
I thought it'd keep going down the stack; I could be remembering incorrectly though).

You have two iterators; once you're inside the second iterator the contact is no longer on
the top of the stack--the contact method is (if there *are* any contact methods). That can
be solved by providing an "id" attribute, thus naming the object of iteration, and allowing
you to refer to it regardless of stack depth. The pseudo-code I provided demonstrated this.

Second of all, your current implementation only displays properties if there are "contactmethodses"
(your pluralizer needs help). The pseudo-code I provided printed the contact name *then* iterated
over contactmethodses.

On a pedantic note, your outer join isn't being "lost", nor is data loading methodology relevant.


[1] Iterator tag:
[2] Property tag:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message