Newbee - How to create a dynamic menu in a Struts Action?

Thomas Bednarz <[email protected]>
Newsgroups gmane.comp.java.struts-menu.user
Message-ID <[email protected]>
Hi,

I usually work with Velocity and not with JSP. However I decided to 
build my menu with JSP and mix Velocity and JSP. The problem is, that I 
have no experience with JSP.

To create a dynamic menu I looked at the database sample. I have the 
following question:

How can I put my menu repository from a Struts Action into a JSP Page 
Context ?????

I have a Struts Action that builds the menu as follows:

    public ActionForward perform(ActionMapping mapping, ActionForm form,
                                 HttpServletRequest request, 
HttpServletResponse response)
    throws IOException, ServletException
    {
        ActionForward af = super.perform(mapping, form, request, response);
        if (af != null)
            return af;
        ........
        buildMenu(session);
        .....
        return (new ActionForward("/Templates/Test.jsp"));
    }
   
    protected void buildMenu(HttpSession session)
    {
        MenuRepository repository = new MenuRepository();
        MenuRepository defaultRepository = (MenuRepository)
        
session.getServletContext().getAttribute(MenuRepository.MENU_REPOSITORY_KEY);
        repository.setDisplayers(defaultRepository.getDisplayers());
       
        MenuComponent mc = new MenuComponent();
        mc.setName("Test Menu 1");
        String title = "Menu Title";
        mc.setTitle(title);
        //mc.setLocation("location");
        repository.addMenu(mc);
       
       // WHERE TO PUT THE REPOSITORY OBJECT (IN WHICH CONTEXT??)
       // I should do something like 
JSPPageContext.setAttribute("reporsitory", repository);
    }

In the Test.jsp I would like do do something like:

    <menu:useMenuDisplayer name="ListMenu" repository="repository">
        <menu:displayMenu name="Test_Menu_1"/>
    </menu:useMenuDisplayer>   

Many thanks for your help!

Tom.
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.