public com.opensymphony.xwork2.ValidationAwareSupport | doPost(java.lang.String namespace, java.lang.String action, java.util.Map params)
HttpServletRequest req = WebContextFactory.get().getHttpServletRequest();
ServletContext servletContext = WebContextFactory.get().getServletContext();
HttpServletResponse res = WebContextFactory.get().getHttpServletResponse();
Map requestParams = new HashMap(req.getParameterMap());
if (params != null) {
requestParams.putAll(params);
} else {
params = requestParams;
}
Map requestMap = new RequestMap(req);
Map session = new SessionMap(req);
Map application = new ApplicationMap(servletContext);
Dispatcher du = Dispatcher.getInstance();
HashMap ctx = du.createContextMap(requestMap,
params,
session,
application,
req,
res,
servletContext);
try {
Configuration cfg = du.getConfigurationManager().getConfiguration();
ValidatorActionProxy proxy = new ValidatorActionProxy(namespace, action, ctx);
cfg.getContainer().inject(proxy);
proxy.prepare();
proxy.execute();
Object a = proxy.getAction();
if (a instanceof ValidationAware) {
ValidationAware aware = (ValidationAware) a;
ValidationAwareSupport vas = new ValidationAwareSupport();
vas.setActionErrors(aware.getActionErrors());
vas.setActionMessages(aware.getActionMessages());
vas.setFieldErrors(aware.getFieldErrors());
return vas;
} else {
return null;
}
} catch (Exception e) {
LOG.error("Error while trying to validate", e);
return null;
}
|