01: package org.strecks.controller.chain.command;
02:
03: import javax.servlet.http.HttpServletRequest;
04:
05: import org.apache.struts.action.ActionForm;
06: import org.apache.struts.chain.commands.ActionCommandBase;
07: import org.apache.struts.chain.contexts.ActionContext;
08: import org.apache.struts.chain.contexts.ServletActionContext;
09: import org.strecks.form.controller.BindingForm;
10: import org.strecks.form.controller.ValidForm;
11: import org.strecks.form.handler.FormWrapper;
12: import org.strecks.form.handler.ValidateBindFormWrapper;
13:
14: /**
15: * Follows <code>CreateActionForm</code> in chain
16: * @author Phil Zoio
17: */
18: public class ProcessActionForm extends ActionCommandBase {
19:
20: private FormWrapper formHandler;
21:
22: public ProcessActionForm() {
23: super ();
24: formHandler = newFormHandler();
25: }
26:
27: protected FormWrapper newFormHandler() {
28: return new ValidateBindFormWrapper();
29: }
30:
31: @Override
32: public boolean execute(ActionContext actionContext)
33: throws Exception {
34:
35: ActionForm form = actionContext.getActionForm();
36:
37: if (form != null) {
38:
39: ServletActionContext sc = (ServletActionContext) actionContext;
40: HttpServletRequest request = sc.getRequest();
41: form = formHandler.wrapForm(form, request);
42:
43: if (form instanceof BindingForm) {
44: formHandler.handleBindingForm((BindingForm) form,
45: request);
46: if (form instanceof ValidForm) {
47: formHandler.handleValidForm((ValidForm) form,
48: request);
49: }
50: }
51:
52: actionContext.setActionForm(form);
53: }
54:
55: return false;
56:
57: }
58:
59: }
|