wood burning stoves 2.0*
The moose likes JSP and the fly likes generate java script code on th fly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "generate java script code on th fly" Watch "generate java script code on th fly" New topic
Author

generate java script code on th fly

Hareesh Ram Chanchali
Ranch Hand

Joined: Jan 31, 2005
Posts: 110
hi,

In my application I need to generate a Java script coded Tree which will be dynamic in nature. This should be generated dynamically by the program.
The nodes in the tree are taken from the database on the fly. Those nodes can be taken and will be used to construct the java script source to generate the required tree.

Another issue may be of java script..how to keep access control for node clicks

plz help me

thanks in advance and will be highly appreciable


Hareesh Ram Chanchali
SCJP 5.0, IBM Certified Solution Designer
Eugene Lucash
Ranch Hand

Joined: Feb 19, 2005
Posts: 77
So what the promlem?

1. Create javascript object "Tree" with method
like addLeaf(level, caption, url); (statically included)
2. The dymanically invoke this method using db's data (dynamicaly generated)

so result of jsp will be like this
<script>
Tree.addLeaf(1, "Folder 1", null);
Tree.addLeaf(2, "Sub Folder 1", "http://.../?sds=1&ddd..");
Tree.addLeaf(2, "Sub Folder 2", "http://.../?sds=2&ddd..");
Tree.addLeaf(1, "Folder 2", null);
</script>

using construst similar to this
<% for (......) { %>
Tree.addLeaf(<%=level>, "<%=caption%>", <%=url%> );
<% } %>

All you need to know is javascript and jsp.
[ February 23, 2005: Message edited by: Eugene Lucash ]
Hareesh Ram Chanchali
Ranch Hand

Joined: Jan 31, 2005
Posts: 110
hi Lucash,

Thank for reply

please be eloborated with the flow of data ...

can please tell how i can keep access control for each node (that is all the nodes are not accessible for all) I want to restrict that access
Eugene Lucash
Ranch Hand

Joined: Feb 19, 2005
Posts: 77
flow highly dependant on structure of database query & resultset.

About access. What security mechanism do you use (db, http declarative, manual)?

To restict access using db you can construct your query in such a way, that
restricted nodes will not be in result.

if you using http roles you can
do
<% if(request.isUserInRole("admin")) { %>
<!-- write node -->
<% } %>
Hareesh Ram Chanchali
Ranch Hand

Joined: Jan 31, 2005
Posts: 110
Levelwise security mechanism will be taken from database
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: generate java script code on th fly
 
Similar Threads
To Eric Pascarello
poroblem with loading xml dom tree
is there any way to generate a TREE / Graph like image by java ?
How to write a javascript function to exapand/collapse all nodes in a TreeMenu
JSF Tree