• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dynamic Menus

 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic