Struts form wizard + LookupDispatchAction

Discussions

Web tier: servlets, JSP, Web frameworks: Struts form wizard + LookupDispatchAction

  1. Struts form wizard + LookupDispatchAction (7 messages)

    Hi all,

    I'm trying to do a form wizard w/o having to download anymore thirdparty plugins like struts-flow or livinglogic.de so i found the example on apache's newbie faq.

    I also created an Action class that extended the LookupDispatchAction.

    I followed the instructions on the LookupDispatchAction javadoc by creating the form-bean entry in my struts-config.xml and made the following jsp changes. In my Action class that extends the LookupDispatchAction, I added the two methods per the instructions:

    public ActionForward add(ActionMapping mapping,
              ActionForm form,
              HttpServletRequest request,
              HttpServletResponse response)
              throws IOException, ServletException {
          // do add
          return mapping.findForward("success");
      }

      public ActionForward delete(ActionMapping mapping,
              ActionForm form,
              HttpServletRequest request,
              HttpServletResponse response)
              throws IOException, ServletException {
          // do delete
          return mapping.findForward("success");
      }

    However it seems that those two, methods are never called. Only the

    public ActionForward execute(...)

    method is invoked when I click on any of the buttons. What am I missing here?

    tia,

    Patrick

    Threaded Messages (7)

  2. In case you're wondering, I did also include that getMapKeyMethod(...)

    protected Map getKeyMethodMap() {
          Map map = new HashMap();
          map.put("button.add", "add");
          map.put("button.delete", "delete");
          return map;
      }

    --patrick
  3. Rsources[ Go to top ]

    did u correctly defined button.add and button.delete in ur resource bundle
    and did u use that correctly from jsp
  4. Rsources[ Go to top ]

    Yes, my resources are working fine.

    The lookupDispatchAction javadoc mentions defining that getKeyMapMethod and adding your methods for the key values of your buttons, but when are those new methods ever invoked?

    I looked at the source code of LookupDispatchAction and it only invokes the getKeyMapMethod when you do a lookupMethoName call.

    Am I suppose to add logic in my execute method that determines the methodName (add,delete,...) and then call the added add(...), delete (...) methods? I thought it was suppose to happen automagically?

    What am I missing here?

    thanks,
    Patrick
  5. Rsources[ Go to top ]

    What I really hate are discussion groups that identify my problem exactly, yet the solution was never solved!!

    In case you sympathize with my dilemma, I think i solved this problem. The execute method is not to be overwridden in your LookupDispatchAction subclass -- you just depend on the getMapKeyMethod to address that. My problem was that my action tags were not properly defined.

    If anybody's interested in a concrete example of the LookupDispatchAction class for a wizard like multipage form, here's the code
  6. Thanks[ Go to top ]

    Thanks for posting your solution. Most of the time people dont't do this once their problem is solved!
  7. page not found[ Go to top ]

    Hi patrick
    I couldnot goto the Code page as it is showing some error message. can you please guide me how to get there.

    bye
    Thanks
    Ramesh
  8. page not found[ Go to top ]

    Sorry, I recently upgrade my website. Check again, that link should redirect you to the proper page. If not here it is:

    http://lacson.name/archives/2004/12/struts_lookupdi.html

    thanks,
    patrick