RE: On the fly menu configuration ?

"Pingili, Madhupal" <[email protected]>
Newsgroups gmane.comp.java.struts-menu.user
Message-ID <[email protected]>
userMenusSorted is an ArrayList of menus that a logged in user will see.

Here is the AppUtils.createUserMenuRepository() code:

    /**
     * Return a MenuRepository, after adding the menus that user is
authorized to see.
     * Any nulls or conversion error returns null.
     * @param userMenus The List of menus that the user is authorized to
see.
     * @param mrp The application scoped MenuRepository.
     * @returns MenuRepository The MenuRepository created with user menus.
     */
    public static MenuRepository createUserMenuRepository(List userMenus,
MenuRepository mrp) {
      //Create Menu Repository and stuff it using menus that the user is
authorized and
      //application scoped MenuRepository.
      MenuRepository userMenuRep = new MenuRepository();

      logDebug.debug("AppUtils: Menu - LoadParam: "  + mrp.getLoadParam() );
      logDebug.debug("AppUtils: Menu - Name: "  + mrp.getName() );

      userMenuRep.addMenuDisplayerMapping(
mrp.getMenuDisplayerMapping("DropDown") );
      userMenuRep.addMenuDisplayerMapping(
mrp.getMenuDisplayerMapping("Simple") );
      userMenuRep.addMenuDisplayerMapping(
mrp.getMenuDisplayerMapping("CoolMenu") );
      userMenuRep.addMenuDisplayerMapping(
mrp.getMenuDisplayerMapping("CoolMenu4") );
      userMenuRep.addMenuDisplayerMapping(
mrp.getMenuDisplayerMapping("MenuForm") );
      userMenuRep.addMenuDisplayerMapping(
mrp.getMenuDisplayerMapping("ListMenu") );
      userMenuRep.addMenuDisplayerMapping(
mrp.getMenuDisplayerMapping("TabbedMenu") );
      userMenuRep.addMenuDisplayerMapping(
mrp.getMenuDisplayerMapping("Velocity") );

      Set menuNames = mrp.getMenuNames();
      for( int k = 0; k < userMenus.size(); k++ ) {
        String roleName = (String) userMenus.get(k);
        Iterator iter = menuNames.iterator();
        while( iter.hasNext() ) {
   	      String menuName = (String) iter.next();
      	  if( roleName.equalsIgnoreCase(menuName) ) {
      	  	userMenuRep.addMenu( mrp.getMenu(menuName) );
            logDebug.debug("AppUtils: MenuNames: "  + menuName );
            break;
      	  }
        }
      }

      return userMenuRep;
    }

I did not find a way to get displayers from existing (default)
Menu_Repository at application scope.
That's why, I had to hard code all displayers names and add them to new
Menu_Repository like:
newMenuRep.addMenuDisplayerMapping(
mrp.getMenuDisplayerMapping("TabbedMenu") );


Reddy Pingili

> -----Original Message-----
> From:	Jean-Baptiste Lievremont [SMTP:[email protected]]
> Sent:	Friday, April 02, 2004 5:14 AM
> To:	struts-menu-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> Subject:	Re: [struts-menu] On the fly menu configuration ?
> 
> Pingili, Madhupal wrote:
> 
> >If  "on the fly" means, keeping menus in the request/session scope, then
> >yes, you can
> >generate menus and stick them in request/session using MenuRepository.
> >e.g.
> >//Create User Menu Repository, stuff it and keep it in session scope.
> >MenuRepository mrp = (MenuRepository)
> >servlet.getServletContext().getAttribute(MenuRepository.MENU_REPOSITORY_K
> EY)
> >;
> >MenuRepository userMenuRep =
> >AppUtils.createUserMenuRepository(userMenusSorted,mrp);
> >  
> >
> What is userMenusSorted in this line ?
> 
> Also where can I find the AppUtils class ? It is nowhere in the 
> struts-menu API.
> 
> >session.setAttribute(MenuRepository.MENU_REPOSITORY_KEY, userMenuRep);
> >//End of User Menu Repository creation.  
> >
> >Struts-menu will pick it up and display only those menus.
> >
> >Reddy Pingili
> >  
> >
> -- 
> | Jean-Baptiste Lièvremont                            |
> |   E-mail : [email protected]        |
> |                            [email protected]         |
> |   Tel    : (+33)6.14.85.19.96                       |
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: IBM Linux Tutorials
> Free Linux tutorial presented by Daniel Robbins, President and CEO of
> GenToo technologies. Learn everything from fundamentals to system
> administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
> _______________________________________________
> struts-menu-user mailing list
> struts-menu-user-TtF/[email protected]
> https://lists.sf.net/lists/listinfo/struts-menu-user


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.