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.

Reply via email to