Make the Navigation Menu user specific

For a workflow application serveral user types are defined. In general, depending on their roles, users have different rights. In particular the navigation menu must be user specific (e.g. some users may have write access, others only read access ).
2 answers

Use of Database for relating user roles to menues

In our application we used the approach to create it flexible by storing the information in database, bascially it consists of 4 tables

UserToRole - Assigns roles to users
ItemToRole - Assigns roles to menuitems

MenuItems may link themselves to upper level items for creating the menu structure. It also contains the ordering of the items. If the menu is built top level items are displayed according to user roles. If the toplevel items have subelements the same check is done again. Each menuItem holds the corresponding links to the jsp pages.


Use role specific configuration files

We implemented a very simple, but flexible solution:
For each user role the configuration file has the following structure (only submenus having level 1 are considered)

For each top level menu item either

= "menuAction.jsp" if there are no submenu items

By analyzing the lines of the file succesively we get the role specific menu structure.

We implemented just this text structure, but the configuration file in XML format would in fact offer a more generally applicable solution.