Hi Matt,

Matt Raible wrote:
If you put the repository in the user's session, that should be used instead.

The following code starts with page scope, then looks in request, session and applications scopes:

        // get the menu repository
        MenuRepository rep =
            (MenuRepository) pageContext.findAttribute(this.repository);

You can override the default name by using repository="yourname" on useMenuDisplayer tag:

    /**
     * This method allows users to override the key used to lookup the
* repository. If not specified - the default repository is used, which is
     * "net.sf.navigator.MENU_REPOSITORY" or
     * UseMenuDisplayerTag.MENU_REPOSITORY_KEY.
     * @param repository
     */
    public void setRepository(String repository) {
        this.repository = repository;
    }
This sounds exactly like what I was looking for. In the meantime, I'd replaced my <menu:displayMenu name="Reports"/> tag with some JSP/Struts/EL that pulled a list I'd pre-loaded into the Session. It works, but much messier than what you've just described.

BTW, is it possible to have the main part of the menu in the Application (as it is currently) and then a submenu in the Session? Does the <menu:displayMenu> tag just hunt through the first repository it finds, or can it be pointed at a different repository?
On Feb 14, 2008, at 6:25 AM, Rob Hills wrote:
My app is based on AppFuse 2.0 + Struts etc and I'm using the default struts-menu to build my app menu.

In this app, each user belongs to a company and a company has an associated set of reports. The spec calls for the reports to be selectable from a dropdown menu and for each company's users to see only their company's
reports.

I have created an ApplicationListener that fires off when the user logs in and loads up the list of reports for that user's company. However, I've discovered that the Struts Menu repository is stored at the Application scope level and so if I modify it for User A from Company A, when User B from Company B logs in, the Reports dropdown
menu for the whole App is changed to that of Company B.

Does anyone know if there's some way of configuring Struts Menu to use a menu repository cached at the Session
level rather than the Application level?
Thanks,

Rob Hills
Waikiki, Western Australia

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to