Populate the form bean (if any) for this request.
Method from org.apache.struts.chain.AbstractPopulateActionForm Detail: |
public boolean execute(Context context) throws Exception {
// Is there a form bean for this request?
ActionForm actionForm = (ActionForm)
context.get(getActionFormKey());
if (actionForm == null) {
return (false);
}
// Reset the form bean property values
ActionConfig actionConfig = (ActionConfig)
context.get(getActionConfigKey());
reset(context, actionConfig, actionForm);
populate(context, actionConfig, actionForm);
handleCancel(context, actionConfig, actionForm);
return (false);
}
|
public String getActionConfigKey() {
return (this.actionConfigKey);
}
Return the context attribute key under which the
ActionConfig for the currently selected application
action is stored.
|
public String getActionFormKey() {
return (this.actionFormKey);
}
Return the context attribute key under which the
ActionForm for the currently selected application
action is stored.
|
public String getCancelKey() {
return (this.cancelKey);
}
|
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 {
context.put(getCancelKey(), Boolean.FALSE);
}
}
|
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);
}
Base implementation assumes that the Context
can be cast to WebContext and copies the parameter
values from the context to the ActionForm .
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
org.apache.struts.chain.servlet.PopulateActionForm .
|
abstract protected void reset(Context context,
ActionConfig actionConfig,
ActionForm actionForm)
|
public void setActionConfigKey(String actionConfigKey) {
this.actionConfigKey = actionConfigKey;
}
Set the context attribute key under which the
ActionConfig for the currently selected application
action is stored.
|
public void setActionFormKey(String actionFormKey) {
this.actionFormKey = actionFormKey;
}
Set the context attribute key under which the
ActionForm for the currently selected application
action is stored.
|
public void setCancelKey(String cancelKey) {
this.cancelKey = cancelKey;
}
|