2
* $Id: MappingDispatchExampleAction.java 383716 2006-03-07 00:04:15Z niallp $
4
* Copyright 2006 The Apache Software Foundation.
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
* you may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
10
* http://www.apache.org/licenses/LICENSE-2.0
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
18
package org.apache.struts.webapp.dispatch;
21
import java.util.HashMap;
22
import javax.servlet.http.HttpServletRequest;
23
import javax.servlet.http.HttpServletResponse;
24
import org.apache.struts.actions.MappingDispatchAction;
25
import org.apache.struts.action.ActionForm;
26
import org.apache.struts.action.ActionForward;
27
import org.apache.struts.action.ActionMapping;
28
import org.apache.struts.action.ActionMessage;
29
import org.apache.struts.action.ActionMessages;
32
* Example DispatchAction.
34
* @version $Rev: 383716 $ $Date: 2006-03-07 00:04:15 +0000 (Tue, 07 Mar 2006) $
36
public class MappingDispatchExampleAction extends MappingDispatchAction {
38
private Map keyMethodMap = new HashMap();
43
* Example "foo" method.
45
* @param mapping The ActionMapping used to select this instance
46
* @param form The optional ActionForm bean for this request
47
* @param request The servlet request we are processing
48
* @param response The servlet response we are creating
50
* @exception Exception if business logic throws an exception
52
public ActionForward doFoo(ActionMapping mapping,
54
HttpServletRequest request,
55
HttpServletResponse response)
60
ActionMessages messages = new ActionMessages();
61
messages.add("foo", new ActionMessage("count.foo.message", fooCount+""));
62
saveMessages(request, messages);
64
return (mapping.findForward("success"));
69
* Example "bar" method.
71
* @param mapping The ActionMapping used to select this instance
72
* @param form The optional ActionForm bean for this request
73
* @param request The servlet request we are processing
74
* @param response The servlet response we are creating
76
* @exception Exception if business logic throws an exception
78
public ActionForward doBar(ActionMapping mapping,
80
HttpServletRequest request,
81
HttpServletResponse response)
85
ActionMessages messages = new ActionMessages();
86
messages.add("bar", new ActionMessage("count.bar.message", barCount+""));
87
saveMessages(request, messages);
89
return (mapping.findForward("success"));