01: /*
02: * Copyright 2005-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
05: * in compliance with the License. You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software distributed under the License
10: * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11: * or implied. See the License for the specific language governing permissions and limitations under
12: * the License.
13: */
14:
15: package org.strecks.action.navigable;
16:
17: import javax.servlet.http.HttpServletRequest;
18:
19: import org.apache.struts.Globals;
20: import org.apache.struts.action.ActionForm;
21: import org.strecks.action.NavigableSubmitAction;
22: import org.strecks.context.ActionContext;
23: import org.strecks.controller.BaseNavigableControllerAction;
24: import org.strecks.controller.annotation.ActionInterface;
25: import org.strecks.form.controller.BindingForm;
26: import org.strecks.navigate.annotation.ReadNavigation;
27: import org.strecks.view.ViewAdapter;
28:
29: /**
30: * Action controller used to handle form submission mechanisms used by action beans which implement the
31: * <code>NavigableSubmitAction</code> interface
32: * @see org.strecks.action.NavigableSubmitAction
33: * @author Phil Zoio
34: */
35: @ActionInterface(name=NavigableSubmitAction.class)
36: @ReadNavigation
37: public class NavigableSubmitController extends
38: BaseNavigableControllerAction {
39:
40: @Override
41: protected ViewAdapter executeAction(Object actionBean,
42: ActionContext context) {
43:
44: NavigableSubmitAction action = (NavigableSubmitAction) actionBean;
45:
46: ActionForm form = context.getForm();
47:
48: HttpServletRequest request = context.getRequest();
49:
50: boolean cancelled = false;
51: if (request.getAttribute(Globals.CANCEL_KEY) != null) {
52: cancelled = true;
53: }
54:
55: //FIXME call deferred form validation here
56:
57: //FIXME call validation methods here
58:
59: if (form instanceof BindingForm && !cancelled) {
60: action.preBind();
61: BindingForm validBindingForm = (BindingForm) form;
62: validBindingForm.bindInwards(actionBean);
63: }
64:
65: if (cancelled)
66: action.cancel();
67: else
68: action.execute();
69:
70: return findActionForward(actionBean, context);
71:
72: }
73: }
|