01: package com.mockrunner.example.struts;
02:
03: import java.util.HashMap;
04: import java.util.Map;
05:
06: import javax.servlet.http.HttpServletRequest;
07: import javax.servlet.http.HttpServletResponse;
08:
09: import org.apache.struts.action.ActionForm;
10: import org.apache.struts.action.ActionForward;
11: import org.apache.struts.action.ActionMapping;
12: import org.apache.struts.actions.LookupDispatchAction;
13:
14: /**
15: * This simple <code>LookupDispatchAction</code> returns
16: * different forwards, depending on the called handler method.
17: * Demonstrates how to test a <code>LookupDispatchAction</code>.
18: */
19: public class ShoppingCartAction extends LookupDispatchAction {
20: protected Map getKeyMethodMap() {
21: Map map = new HashMap();
22: map.put("button.add", "add");
23: map.put("button.order", "order");
24: return map;
25: }
26:
27: public ActionForward add(ActionMapping mapping, ActionForm form,
28: HttpServletRequest request, HttpServletResponse response)
29: throws Exception {
30: return mapping.findForward("add");
31: }
32:
33: public ActionForward order(ActionMapping mapping, ActionForm form,
34: HttpServletRequest request, HttpServletResponse response)
35: throws Exception {
36: return mapping.findForward("order");
37: }
38: }
|