February 2005
Intermediate to advanced
528 pages
12h 53m
English
You want users to have a wizard-style page flow experience.
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 ...