Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

generate java script code on th fly

 
Hareesh Ram Chanchali
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Eugene Lucash
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Levelwise security mechanism will be taken from database
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic