aspose file tools
The moose likes Struts and the fly likes recursive iteration Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "recursive iteration" Watch "recursive iteration" New topic
Author

recursive iteration

Gigi Kent
Ranch Hand

Joined: Nov 30, 2004
Posts: 40
Hello.
I have a problem and I don't know how to do it and maybe anyone has an idea.
So, it is like this:
I want to make a dinamicaly tree with values pooled out from a database.
The tree is a copy of a regular javascript tree menu.It is a menu something like in the Windos explorer: when you click '+' the tree expands with the subitems.On every subitem you can click on the '+' and is the same. I hope you understand about what kind of tree I'm talking about.
I don't know how to do it in a jsp page. I'm thinking at iterate tag but it is necesairy to have something recursiv but I don't have any idea.
Can someone give me a tip?
Thanks alot.
Bye.
Venkatraman Kandaswamy
Ranch Hand

Joined: Jul 07, 2004
Posts: 120
For the tree like navigation check treeview.

Here are the steps I will suggest

*Embed the treeview javascript in your JSP page at the top
*Inside the Javascript code - you will be writing lot of JSP statements.
*You will have to iterate on 2 loops
*In first loop, you will write the parent node name onto the javascript tree code where the parent node is.
*In second loop, you will write the child nodes under the parent node

By write I mean <bean:write tags etc..weave your JSP code inside javascript.

Have fun !!


--Venkatraman<br />SCJP 1.4<br /><a href="http://kvrlogs.blogspot.com" target="_blank" rel="nofollow">blog</a>
Gigi Kent
Ranch Hand

Joined: Nov 30, 2004
Posts: 40
Thanks for yours ideas but I want to do something without javascript.So for every click the page is reloaded.
Any ideas?
Venkatraman Kandaswamy
Ranch Hand

Joined: Jul 07, 2004
Posts: 120
oh ok. Then its even simpler.

let me write the pseduo code.

lets assume you send showParentId in request


you can accomplish all these with JSTL tags.
[ July 20, 2005: Message edited by: Venkatraman Kandaswamy ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
When there are many good open source javascript tree controls out there, I can't for the life of me think of a good reason to re-write them using JSP in a way that would require a trip to the server every time a node is expanded. In my opinion, javaScript really is the way to go on this type of control because it separates what can easily be done on the client (expanding nodes) and what has to be done on the server (perfoming a task when a node is clicked).

If you really want to do this, I'd suggest looking at the javascript in one of the open source tree controls, and duplicating the logic using java.

If it were me, though, I'd follow Venkatraman's suggestion.


Merrill
Consultant, Sima Solutions
Gigi Kent
Ranch Hand

Joined: Nov 30, 2004
Posts: 40
Thanks Venkatraman Kandaswamy for pseudocod but every chils may have other child and every child of a child may hava anoters childs and so on.
So..
The expanding is not a problem because I will display all the nodes expanded without possibility to expand.
Actually, I'm copying a javascript tree into a jsp expanded tree.
My problem is filling the tree.
Thanks again.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
This type of processing can be accomplished through recursive calls to a method. Here is an example:



This will crawl through a tree structure until finally all child nodes are null or empty.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: recursive iteration
 
Similar Threads
Updating a JSP session attribute and html code on mouse click
Stamping an Image
JSP Tree Menu Problem
unable to access the ejb deployed on weblogic application server
@OneToMany/ManyToOne and @OneToOne relationship between same entities.