Yes
----- Original Message ----- 
From: "David Schwartz" <[EMAIL PROTECTED]>
To: "'Tag Libraries Users List'" <[EMAIL PROTECTED]>
Sent: Friday, April 09, 2004 10:29 AM
Subject: RE: Recursive Functionality with Tags


> Is your item list coming from a database?
>
> David Schwartz
>
> -----Original Message-----
> From: Jeff Brewer [mailto:[EMAIL PROTECTED]
> Sent: Friday, April 09, 2004 10:00 AM
> To: [EMAIL PROTECTED]
> Subject: Recursive Functionality with Tags
>
> I'm new to Tags and still hip-deep in getting my first JSP project off the
> ground and very much appreciate all the great support in this forum. Thank
> You! My question is at the end of all this (in case you want to skip over
> the rest)...
>
> **BACKGROUND
> I have an "outline" or "directory" type structure that consists of an
> ArrayList that contains objects that have ArrayLists full of the same kind
> of objects that each have ArrayLists full of.... and so on. I want my HTML
> page to look something like this with each sub-item indented:
>
> FIRST ITEM
>      FIRST SUB-ITEM
>      SECOND SUB-ITEM
>           FIRST SUB-ITEM
>      THIRD SUB-ITEM
> SECOND ITEM
> THIRD ITEM
>      FIRST SUB-ITEM
> FOURTH ITEM
>
> **CURRENT SOLUTION
> I made this work on my JSP page using the following code:
>
> <%
>      // get the ArrayList from the request
>      ArrayList al = (ArrayList) request.getAttribute("issuesList");
> %>
> <%=writeIssues(al, new String(), 50) // call the writeIssues function -
> returns the outline%>
> <%!
> String writeIssues(ArrayList al, String myOutput, int indent) {
>     // sort the array list alphabetically
>     Collections.sort(al);
>      Iterator iter = al.iterator();
>      Issue myIssue = null;
>      while (iter.hasNext()) {
>           myIssue = (Issue) iter.next();
>          // append the string with this issue title
>           myOutput = new String(myOutput + "<p style=\"margin-left: " +
> indent + ";\">" + myIssue.getName() + "</p>\n");
>           // recurse by passing this issue's ArrayList, the ever-growing
> string, and a new indent value
>           myOutput = new String(writeIssues(myIssue.getChildren(),
myOutput,
> indent + 50));
>      }
>      return myOutput;
>  }
> %>
>
>
> **QUESTION
> Can I do this somehow in JSTL?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to