Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom Tags to create dynamic links

 
Grishma Dube
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I need to design an arch. where i need to show dynamic links in left navigation bar depending on the role of the user.

We were thinking on 2 standard approaches i.e. either keeping the links in the database or using xml. But I would like to know, how can we make use of custom tags?

I'm getting user role from the session and by making use of the role, I need to generate dynamic left menu based on the custome tags. I need to know, how will be the flow? means after getting the role id from session what will be the nxt activity? where will i store the links, etc.?


Thanx & Regards,

Grishma
[ February 24, 2005: Message edited by: Grishma Dube ]
 
Vijay Sharma
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Grishma,
I think for dynamic link generation you have to go for xml.B'coz that is a better option,xml has several features.That is also tag based.So,you can easily integrate with your jsp page.
Bye
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should use db - the permissions for the role should be defined in the db (you could use xml too, but if the permissions are defined in a complex way, stick to db, it would make querying easier - after all left nav is not the only place you require permissions, right?)
I cannot understand why you require to store the left nav links any place. Just code it in your custom tag and based on permissions, hide/display it.

For me, the flow would be

servlet -> gets the request, fwds it to the correct web-handler
web-handler -> gets the role, accesses db, loads the permission (& other processing), sets all data including the permission in request attribute.
returns to servlet
servlet -> fwds to jsp
jsp -> uses custom tags
custom tags -> picks the permission from the request attr and hides/displays links and other data.

ram.
 
Grishma Dube
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Ramprasad.

I need some clarification.

1. I will get user role from session after successful authenticated by the Login.jsp.

2. The home will be dynamically generated for each user. So before displaying the home page, it will take the user role and will refer the tag lib for all the link and contents available for him. And after refering to the tag lib, it will display the home page with only these links and contents permissible to him.

Will it work perfectly? tell me if we've any disadvantages of using this approach
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

1. I will get user role from session after successful authenticated by the Login.jsp.


If you are saying that the jsp would authenticate, pick up the role and store it in session, then i guess it's fine. A word of caution, dont overload the session object with too much data. You can pass a lot of data around by storing it in the request object too. You will have to judiciously use a mix of session and request objects. For example, for userid and role, storing the same in session is fine


2. The home will be dynamically generated for each user. So before displaying the home page, it will take the user role and will refer the tag lib for all the link and contents available for him. And after refering to the tag lib, it will display the home page with only these links and contents permissible to him.

i dont understand what you mean by 'refer the tag lib for all the link and contents available for him'. The tag is supposed to spit out html, not return you such data. If you require to do such processing, use a web-handler or a middleware component, which given a role, returns the permissible actions. The tag then should display the html based on the permissible actions.


Will it work perfectly? tell me if we've any disadvantages of using this approach

pls read that i said in #2 above. Even if your #2 was perfect (which it isnt), I would be really stretched to certify that a particular approach is perfect. That's what design practises are for and each has its own advantages and disadvantages and you should ideally pick and choose per your requirements. A lot of thinking into the future as to how you wish your product and codebase should develop often helps you design futuristically. Happy developing :-)

ram.
 
Grishma Dube
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx a lot Ram
 
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!