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 org.apache.struts.action.ActionForm;
18: import org.strecks.action.NavigableFormAction;
19: import org.strecks.context.ActionContext;
20: import org.strecks.controller.BaseNavigableControllerAction;
21: import org.strecks.controller.annotation.ActionInterface;
22: import org.strecks.form.controller.BindingForm;
23: import org.strecks.navigate.annotation.ReadNavigation;
24: import org.strecks.view.ViewAdapter;
25:
26: /**
27: * Action controller used to handle form rendering mechanisms used by action beans which implement
28: * the <code>NavigableFormAction</code> interface
29: * @see org.strecks.action.NavigableFormAction
30: * @author Phil Zoio
31: */
32: @ActionInterface(name=NavigableFormAction.class)
33: @ReadNavigation
34: public class NavigableFormController extends
35: BaseNavigableControllerAction {
36:
37: @Override
38: protected ViewAdapter executeAction(Object actionBean,
39: ActionContext context) {
40:
41: NavigableFormAction action = (NavigableFormAction) actionBean;
42:
43: ActionForm form = context.getForm();
44:
45: boolean hasErrors = hasErrors(context);
46: action.setInputError(hasErrors);
47:
48: if (form instanceof BindingForm && !hasErrors) {
49: BindingForm bindingForm = (BindingForm) form;
50: bindingForm.setBindOutwards(true);
51: }
52:
53: action.execute();
54:
55: if (form instanceof BindingForm) {
56: BindingForm validBindingForm = (BindingForm) form;
57:
58: if (validBindingForm.getBindOutwards()) {
59: validBindingForm.bindOutwards(actionBean);
60: }
61: }
62:
63: return findActionForward(actionBean, context);
64:
65: }
66:
67: }
|