List of usage examples for org.apache.commons.chain.web WebContext getParamValues
public abstract Map getParamValues();
Return an immutable Map
that maps request parameter names to the set of all values (as a String array).
From source file:org.apache.struts.chain.AbstractPopulateActionForm.java
/** * <p>Base implementation assumes that the <code>Context</code> * can be cast to <code>WebContext</code> and copies the parameter * values from the context to the <code>ActionForm</code>.</p> * * <p>Note that this implementation does not handle "file uploads" * because as far as I know there is no API for handling that without * committing to servlets -- in a servlet environment, use * <code>org.apache.struts.chain.servlet.PopulateActionForm</code>.</p> * * @param context//from w w w .ja v a 2s . c om * @param actionConfig * @param actionForm * @throws Exception */ protected void populate(Context context, ActionConfig actionConfig, ActionForm actionForm) throws Exception { WebContext wcontext = (WebContext) context; Map paramValues = wcontext.getParamValues(); Map parameters = new HashMap(); String prefix = actionConfig.getPrefix(); String suffix = actionConfig.getSuffix(); Iterator keys = paramValues.keySet().iterator(); while (keys.hasNext()) { String name = (String) keys.next(); String stripped = name; if (prefix != null) { if (!stripped.startsWith(prefix)) { continue; } stripped = stripped.substring(prefix.length()); } if (suffix != null) { if (!stripped.endsWith(suffix)) { continue; } stripped = stripped.substring(0, stripped.length() - suffix.length()); } parameters.put(stripped, paramValues.get(name)); } BeanUtils.populate(actionForm, parameters); }
From source file:org.apache.struts.chain.AbstractPopulateActionForm.java
protected void handleCancel(Context context, ActionConfig actionConfig, ActionForm actionForm) throws Exception { WebContext wcontext = (WebContext) context; Map paramValues = wcontext.getParamValues(); // Set the cancellation attribute if appropriate if ((paramValues.get(org.apache.struts.taglib.html.Constants.CANCEL_PROPERTY) != null) || (paramValues.get(org.apache.struts.taglib.html.Constants.CANCEL_PROPERTY_X) != null)) { context.put(getCancelKey(), Boolean.TRUE); wcontext.getRequestScope().put(Globals.CANCEL_KEY, Boolean.TRUE); } else {/*from www.j a va 2 s .c o m*/ context.put(getCancelKey(), Boolean.FALSE); } }