struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Struts Newsgroup ( <>
Subject [Off Topic] Iterating through Parents/children help
Date Tue, 02 Jul 2002 01:25:01 GMT
Subject: [Off Topic] Iterating through Parents/children help
From: "Matt Raible" <>
I have an difficult architecture problem.  Please help if you can.  Below
are two tables that are linked by catalog_id.



So basically, these two tables are used to render the following in the

My First Catalog Entry
  -- URL to detail Entry
  -- URL to detail Entry

My Second Catalog Entry
  -- URL to detail Entry

... you get the picture.

My problem comes in in that a catalog entry can be a child of another
catalog entry (not a detail entry).  So you'd end up with something like

My First Catalog Entry
  -- 1
  -- 2
  My Second Catalog Entry
    -- 3
    My Third Catalog Entry....

I need help with (1) How do I prepare this data for display on a page, and
(2) How do I design my page without knowing how many levels deep to go?

Here are my solutions to date:

1.  I query the catalog table, and create an ArrayList of CatalogForm's
(JavaBeans).  As I'm adding a CatalogForm to the arraylist, I use the
catalog_id to get the children of that catalog entry and set them as a
Vector of DetailForm's on the CatalogForm.  This works great without the
parent concept.  With the parent concept, maybe I should keep what I'm
doing, but then lookup through the ArrayList and see if any CatalogForm's
have parents.  If so, set the CatalogForm as a ChildForm on it's parent.

2.  Use JSTL and <c:forEach> to iterate through the catalogForm's and
display the name and the detail's information.  I can add a few more
<c:forEach> tags, but this will only allow the architecture to traverse the
number of levels that I've defined in my JSP.  Is there anyway to allow for
infinite levels?  Maybe some sort of reflection - or even using XML and XSL?
Any and all ideas are welcome.

Finally, I am only responsible for displaying this data, nothing has to be
updated - that's up to another application that's already been written.



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

View raw message