Well with the LookupDispatchAction class you can name a parameter to be used 
to determine what method to execute. In this instance The "Next" and "Previous" 
buttons would point to a same parameter to be used.

eg.

<html:form...>
    <html:submit property="method">
        <bean:message key="button.previous" />
    </html:submit>
    <html:submit property="method">
        <bean:message key="button.moreSearches" />
    </html:submit>
    <html:submit property="method">
        <bean:message key="button.generateReport" />
    </html:submit>
</html:form>

Now the code in the LookupDispatchAction class would look something like this:

public class MyAction extends LookupDispatchAction {
    protected java.util.Map getKeyMethodMap() {
        Map map = new HashMap();
        map.put("button.previous", "previous");
        map.put("button.next", "next");
        return map;
    }
    
    public ActionForward previous(ActionMapping mapping, ActionForm form,
                                  HttpServletRequest request, HttpServletResponse 
response)
                                  throws IOException, ServletException {
        String target = "previous";
        ...
        return (ActionForward)mapping.findForward(target);
    }

    public ActionForward next(ActionMapping mapping, ActionForm form,
                              HttpServletRequest request, HttpServletResponse response)
                              throws IOException, ServletException {
        String target = "next";
        ...
        return (ActionForward)mapping.findForward(target);
    }


So both submit buttons would go to the next page, and within that action you would
transfer control to the previous or next pages.


Cheers
Rodney


-----Original Message-----
From: Michael Muller [mailto:[EMAIL PROTECTED]
Sent: Friday, 11 July 2003 9:41 AM
To: Struts Users Mailing List
Subject: Re: best way to build a wizard



I'm not sure that really solves my problem.  What do I put as the 
"input" for this action?  I can't use the same action; whatever 
attribute I used to indicate that I want to move to the next page would 
still be in the system, so validation failures would bring me to the 
next page rather than the same page.

I'm pondering an approach with two actions, a "next page" action which 
has a "same page" action as its input.

   -- Mike

Rodney Paul wrote:

> Check out the lookupDispatchAction classes.
> These classes were designed specifically for Actions which require more
> than one execute method (in this instance a method for back and next).
> That is what I have used, and is perfect for use when developing wizard applications.
> 
> Cheers
> Rodney
> 
> -----Original Message-----
> From: Michael Muller [mailto:[EMAIL PROTECTED]
> Sent: Friday, 11 July 2003 8:41 AM
> To: Struts Users Mailing List
> Subject: Re: best way to build a wizard
> 
> 
> 
> It turns out that I can't pass the action into the html:form tag using 
> tiles; that would involve nesting JSP tags.  Grr.
> 
> I guess my only recourse is to have the open html:form tag in the 
> inserted body and the close html:form tag in the template.  Ick.
> 
> So now I'm trying to figure out a way to have one one action mapping. 
> Any ideas?  Or alternative approaches?
> 
>    -- Mike
> 
> Michael Muller wrote:
> 
>>My app has a bunch of wizard-style forms.  I have one "NextPageAction" 
>>Action class, and an separate mapping for each page.  The mappings all 
>>bind to the same form bean (a DynaValidatorForm) and invoke the 
>>"NextPageAction".
>>
>>I was hoping to have only one action mapping, with a whole bunch of 
>>forwards for "page1", "page2", etc.  The problem that prevents me from 
>>having one action mapping is validation:  I need the "input" attribute 
>>to redirect me to the correct wizard screen.
>>
>>So I went back to having lots of mappings.  No big deal.  Until...
>>
>>I factored the "next" and "back" buttons into the template.  With those 
>>buttons, wend the closing "html:form" tag.  Makes sense to move the 
>>opening "html:form" tag into the template, too, right?  Oops, my action 
>>is in there.
>>
>>What do I do?
>>
>>I could leave the closing tag in the template and the opening tag in the 
>>inserted body.  Gross.
>>
>>I could try and pass the action into the template through my tiles-defs. 
>> That's kinda kludgy, too.
>>
>>I'm back to thinking I should have one action mapping.  But I don't know 
>>how to accomplish this.
>>
>>Suggestions?
>>
>>Thanks,
>>
>>Mike
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 




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


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

Reply via email to