aspose file tools*
The moose likes Struts and the fly likes Dynamic Menus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dynamic Menus" Watch "Dynamic Menus" New topic
Author

Dynamic Menus

Yogendra Joshi
Ranch Hand

Joined: Apr 04, 2006
Posts: 213
Hello Friends ,

I would like to have some help from you here... In my application User Profiling is needed. I mean to say , when user X logs in the Appl he should be able to see some menus , while when i as an Admin login i should be able to see all the menus.

I want to know how this is possible. I am using Struts 1.2 and MySql5.0 as DB Server...

Please help me with this.

Thanks in Advance.
Yogendra Joshi.


Meri Zindagi Hain Tab Tak.. Jab Tak Tera Sahara.... Har Taraf Tu Hi Tu Hain SAI Tera Hi Hain Nazara.....
Ravi Kumar
Greenhorn

Joined: Sep 07, 2005
Posts: 24
Hello,

Steps to follow --
1.First Get the username/admin name from DB.
2.On the page corresponding to that userid set the options. Say suppose only admin can delete/update records. Then when you display those buttons/links check for userid and show only if he is an admin.

Hope this helps.
Tong Wang
Ranch Hand

Joined: Jun 20, 2005
Posts: 44
A better way is to put the logic that determines what menus to show in the business layer and pass the result in a colletion to the jsp. The jsp will display whatever menu items in that collection.
Yogendra Joshi
Ranch Hand

Joined: Apr 04, 2006
Posts: 213
Originally posted by Tong Wang:
A better way is to put the logic that determines what menus to show in the business layer and pass the result in a colletion to the jsp. The jsp will display whatever menu items in that collection.



Hello Ravi / Tong ,

Thanks for your suggestions.

Tong , Can you elaborate more on how this can be achieved. I mean we have a table called user_access wherein we have users, their passwords and roleid , Based on his / her role i need to decide what menus to show. Also one more question is how to set What menus for what users ? Does it have to be configured in the Database or in the JS file ? I am somewhat confused.

Please help.

Thanks in Advance.
Yogendra N Joshi
Tong Wang
Ranch Hand

Joined: Jun 20, 2005
Posts: 44
Yogendra,

Bottom line: you have to code this logic somewhere (the logic for determining what menus to show for different users/roles), but the best place for this logic is not in you JSPs. Following MVC model, this is considered model part and should live in session beans. Your JSP has no knowledge about the differences in menu display, it should simply display whatever menus are passed to it.

However, to make that work, you need to come up with a way to represent the menu object and passing a list of menu objects from ejb to jsp. For example, a MenuItem transfer object can be created, which contains properties related to the menu, such as label, link, etc.

Hope this helps.
Tong
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamic Menus