use of org.apache.struts.action.ActionForm in project sonarqube by SonarSource.
the class ExceptionHandler method handle.
// ------------------------------------------------------- Protected Methods
protected ForwardConfig handle(ActionContext context, Exception exception, ExceptionConfig exceptionConfig, ActionConfig actionConfig, ModuleConfig moduleConfig) throws Exception {
// Look up the remaining properties needed for this handler
ServletActionContext sacontext = (ServletActionContext) context;
ActionForm actionForm = (ActionForm) sacontext.getActionForm();
HttpServletRequest request = sacontext.getRequest();
HttpServletResponse response = sacontext.getResponse();
// Handle this exception
org.apache.struts.action.ExceptionHandler handler = (org.apache.struts.action.ExceptionHandler) ClassUtils.getApplicationInstance(exceptionConfig.getHandler());
return (handler.execute(exception, exceptionConfig, (ActionMapping) actionConfig, actionForm, request, response));
}
use of org.apache.struts.action.ActionForm in project sonarqube by SonarSource.
the class RequestUtils method createActionForm.
/**
* <p>Create and return an <code>ActionForm</code> instance appropriate to
* the information in <code>config</code>.</p>
*
* <p>Does not perform any checks to see if an existing ActionForm exists
* which could be reused.</p>
*
* @param config The configuration for the Form bean which is to be
* created.
* @param servlet The action servlet
* @return ActionForm instance associated with this request
*/
public static ActionForm createActionForm(FormBeanConfig config, ActionServlet servlet) {
if (config == null) {
return (null);
}
ActionForm instance = null;
// Create and return a new form bean instance
try {
instance = config.createActionForm(servlet);
if (log.isDebugEnabled()) {
log.debug(" Creating new " + (config.getDynamic() ? "DynaActionForm" : "ActionForm") + " instance of type '" + config.getType() + "'");
log.trace(" --> " + instance);
}
} catch (Throwable t) {
log.error(servlet.getInternal().getMessage("formBean", config.getType()), t);
}
return (instance);
}
use of org.apache.struts.action.ActionForm in project sonarqube by SonarSource.
the class ConfigHelper method getActionForm.
/*
* <p>
* Retrieve and return the <code>ActionForm</code> bean associated with
* this mapping, creating and stashing one if necessary. If there is no
* form bean associated with this mapping, return <code>null</code>.
* </p>
*/
public ActionForm getActionForm() {
// Is there a mapping associated with this request?
ActionMapping mapping = getMapping();
if (mapping == null) {
return (null);
}
// Is there a form bean associated with this mapping?
String attribute = mapping.getAttribute();
if (attribute == null) {
return (null);
}
// Look up the existing form bean, if any
ActionForm instance;
if ("request".equals(mapping.getScope())) {
instance = (ActionForm) this.request.getAttribute(attribute);
} else {
instance = (ActionForm) this.session.getAttribute(attribute);
}
return instance;
}
use of org.apache.struts.action.ActionForm in project sonarqube by SonarSource.
the class TestCopyFormToContext method testLookupByNameAndRequestScope.
public void testLookupByNameAndRequestScope() throws Exception {
CopyFormToContext command = new CopyFormToContext();
String formName = "foo";
command.setFormName(formName);
command.setScope("request");
command.setToKey(POST_EXECUTION_CONTEXT_KEY);
assertNull(context.get(POST_EXECUTION_CONTEXT_KEY));
assertNull(context.getRequestScope().get(formName));
assertNull(context.getSessionScope().get(formName));
command.execute(context);
assertNotNull(context.get(POST_EXECUTION_CONTEXT_KEY));
assertNotNull(context.getRequestScope().get(formName));
assertNull(context.getSessionScope().get(formName));
assertSame(context.get(POST_EXECUTION_CONTEXT_KEY), context.getRequestScope().get(formName));
ActionForm theForm = (ActionForm) context.get(POST_EXECUTION_CONTEXT_KEY);
assertTrue(theForm instanceof MockFormBean);
}
use of org.apache.struts.action.ActionForm in project sonarqube by SonarSource.
the class TestCopyFormToContext method testLookupByActionPath.
public void testLookupByActionPath() throws Exception {
CopyFormToContext command = new CopyFormToContext();
command.setActionPath("/Test");
command.setToKey(POST_EXECUTION_CONTEXT_KEY);
// we know this, even though it's not being used for the lookup.
String formName = "foo";
assertNull(context.get(POST_EXECUTION_CONTEXT_KEY));
assertNull(context.getRequestScope().get(formName));
assertNull(context.getSessionScope().get(formName));
command.execute(context);
assertNotNull(context.get(POST_EXECUTION_CONTEXT_KEY));
assertNotNull(context.getRequestScope().get(formName));
assertNull(context.getSessionScope().get(formName));
assertSame(context.get(POST_EXECUTION_CONTEXT_KEY), context.getRequestScope().get(formName));
ActionForm theForm = (ActionForm) context.get(POST_EXECUTION_CONTEXT_KEY);
assertTrue(theForm instanceof MockFormBean);
}
Aggregations