01: package org.strecks.controller.chain.command;
02:
03: import javax.servlet.ServletException;
04: import javax.servlet.http.HttpServletRequest;
05:
06: import org.apache.struts.action.ActionForm;
07: import org.apache.struts.chain.contexts.ActionContext;
08: import org.apache.struts.chain.contexts.ServletActionContext;
09: import org.apache.struts.config.ActionConfig;
10: import org.apache.struts.util.RequestUtils;
11: import org.strecks.form.handler.FormPopulateSource;
12: import org.strecks.form.handler.FormPopulateSourceImpl;
13:
14: /**
15: * Replaces <code>PopulateActionForm</code> in chain
16: * @author Phil Zoio
17: */
18: public class PopulateActionForm extends
19: org.apache.struts.chain.commands.servlet.PopulateActionForm {
20:
21: private FormPopulateSource formPopulateSource;
22:
23: public PopulateActionForm() {
24: super ();
25: formPopulateSource = newFormPopulateSource();
26: }
27:
28: protected FormPopulateSource newFormPopulateSource() {
29: return new FormPopulateSourceImpl();
30: }
31:
32: @Override
33: protected void populate(ActionContext context,
34: ActionConfig actionConfig, ActionForm actionForm)
35: throws Exception {
36: final ServletActionContext sc = (ServletActionContext) context;
37: final ActionForm form = sc.getActionForm();
38: final HttpServletRequest request = sc.getRequest();
39: ActionForm wrappedForm = formPopulateSource.prePopulate(form,
40: request);
41:
42: populateForm(actionConfig, request, wrappedForm);
43: }
44:
45: protected void populateForm(ActionConfig actionConfig,
46: final HttpServletRequest request, ActionForm wrappedForm)
47: throws ServletException {
48: RequestUtils.populate(wrappedForm, actionConfig.getPrefix(),
49: actionConfig.getSuffix(), request);
50: }
51:
52: }
|