O'Reilly logo

Jakarta Struts Cookbook by Bill Siggelkow

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.6. Creating a Wizard-Style Page Flow

Problem

You want users to have a wizard-style page flow experience.

Solution

Implement a subclass of LookupDispatchAction that supports operations for the navigational functions—previous, next, and finish—and template methods for the business logic. For each discrete step of the workflow, extend this subclass, placing the business logic for each step in the provided template methods. (See Example 7-4.)

Example 7-4. LookupDispatchAction for wizards

package com.oreilly.strutsckbk.ch07; import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.actions.LookupDispatchAction; public class WizardLookupDispatchAction extends LookupDispatchAction { public WizardLookupDispatchAction( ) { keyMethodMap = new HashMap( ); keyMethodMap.put("button.previous", "doPrevious"); keyMethodMap.put("button.next", "doNext"); keyMethodMap.put("button.finish", "doFinish"); } public ActionForward doPrevious( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { processPrevious(mapping, form, request, response); return mapping.findForward("previous"); } protected void processPrevious( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required