01: /*
02: * Copyright 2004, 2005, 2006 Odysseus Software GmbH
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package de.odysseus.calyxo.demo.struts;
17:
18: import javax.servlet.http.HttpServletRequest;
19: import javax.servlet.http.HttpServletResponse;
20:
21: import org.apache.struts.action.Action;
22: import org.apache.struts.action.ActionForm;
23: import org.apache.struts.action.ActionForward;
24: import org.apache.struts.action.ActionMapping;
25: import org.apache.struts.action.ActionMessage;
26: import org.apache.struts.action.ActionMessages;
27:
28: /**
29: * Create and save error messages.
30: *
31: * @author Christoph Beck
32: */
33: public class MessagesAction extends Action {
34: /**
35: * Create and save error messages.
36: */
37: public ActionForward execute(ActionMapping mapping,
38: ActionForm form, HttpServletRequest request,
39: HttpServletResponse response) throws Exception {
40:
41: ActionMessages messages = new ActionMessages();
42: messages.add("foo", new ActionMessage("test", "foo error"));
43: messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
44: "test", "global error"));
45: saveErrors(request, messages);
46:
47: return mapping.findForward("success");
48: }
49: }
|