Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Struts logic:iterator for 2d array

Reply
Thread Tools

Struts logic:iterator for 2d array

 
 
Trevor
Guest
Posts: n/a
 
      04-02-2008
Hi,

I am using Struts 1.3 with Hibernate. If I run a simple HQL query in one of
my data access objects (e.g. "from users as u"), this returns a list to my
actionform which I can iterate through in my jsp as follows:

<logic:iterate id="usersForm" name="usersForm" property="allusers"
scope="request">
<bean:write name="usersForm" property="firstname"/>
<bean:write name="usersForm" property="lastname"/>
</logic:iterate>

The above works fine. However when trying to run a query that joins two
tables together (e.g. "from users as u inner join u.addresses as a") this
returns a 2D list in the format:

Element 0
User
Address
Element 1
User
Address

Which I cannot use in my jsp as the <logic:iterate> is iterating over the
top-level elements and not the user/address objects. I think I need to have
nested <logic:iterate> tags but not sure of the syntax or how this affects
my actionform.

Any help of guidence on this would be very much appreciated.

Thanks
Trev



 
Reply With Quote
 
 
 
 
Danno
Guest
Posts: n/a
 
      04-02-2008
On Apr 2, 8:51 am, "Trevor" <(E-Mail Removed)> wrote:
> Hi,
>
> I am using Struts 1.3 with Hibernate. If I run a simple HQL query in one of
> my data access objects (e.g. "from users as u"), this returns a list to my
> actionform which I can iterate through in my jsp as follows:
>
> <logic:iterate id="usersForm" name="usersForm" property="allusers"
> scope="request">
> <bean:write name="usersForm" property="firstname"/>
> <bean:write name="usersForm" property="lastname"/>
> </logic:iterate>
>
> The above works fine. However when trying to run a query that joins two
> tables together (e.g. "from users as u inner join u.addresses as a") this
> returns a 2D list in the format:
>
> Element 0
> User
> Address
> Element 1
> User
> Address
>
> Which I cannot use in my jsp as the <logic:iterate> is iterating over the
> top-level elements and not the user/address objects. I think I need to have
> nested <logic:iterate> tags but not sure of the syntax or how this affects
> my actionform.
>
> Any help of guidence on this would be very much appreciated.
>
> Thanks
> Trev


I don't know how much help you will get, since people have started
using some modern web frameworks, and Struts has also evolved from
1.3. Try to nest the logic:iterate tags yourself and see if that
works. You can also look into using JSTL to include in your Struts
package which definitely provides the nesting capability. If you are
doing a greenfield project then very much consider a modern web
framework like Seam, Grails, Wicket, or Struts 2.0.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it safe to point to Internet for locating struts DTD files in struts TLDs and XML files? Katie Wright Java 8 01-07-2005 03:37 PM
[Struts] Newbie - For ActionForm population, must I use Struts taglib? Pratap Das Java 2 04-05-2004 07:42 PM
[Struts]output javascript in struts perform() sin Java 3 02-22-2004 08:27 AM
Integrate a Struts app with a non-struts app jc1771 Java 0 12-28-2003 06:36 PM
Struts Installation - missing struts.tld??? Jason Us Java 0 10-03-2003 11:36 PM



Advertisments