Search in sources :

Example 31 with ActionMapping

use of org.apache.struts.action.ActionMapping in project sonar-java 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));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) AbstractExceptionHandler(org.apache.struts.chain.commands.AbstractExceptionHandler) ActionMapping(org.apache.struts.action.ActionMapping) ActionForm(org.apache.struts.action.ActionForm) ServletActionContext(org.apache.struts.chain.contexts.ServletActionContext) HttpServletResponse(javax.servlet.http.HttpServletResponse)

Example 32 with ActionMapping

use of org.apache.struts.action.ActionMapping in project sonar-java by SonarSource.

the class ValidateActionForm method validate.

// ------------------------------------------------------- Protected Methods
/**
 * <p>Call the <code>validate()</code> method of the specified form bean,
 * and return the resulting <code>ActionErrors</code> object.</p>
 *
 * @param context    The context for this request
 * @param actionForm The form bean for this request
 */
protected ActionErrors validate(ActionContext context, ActionConfig actionConfig, ActionForm actionForm) {
    ServletActionContext saContext = (ServletActionContext) context;
    ActionErrors errors = (actionForm.validate((ActionMapping) actionConfig, saContext.getRequest()));
    // Special handling for multipart request
    if ((errors != null) && !errors.isEmpty()) {
        if (actionForm.getMultipartRequestHandler() != null) {
            if (log.isTraceEnabled()) {
                log.trace("  Rolling back multipart request");
            }
            actionForm.getMultipartRequestHandler().rollback();
        }
    }
    return errors;
}
Also used : ActionMapping(org.apache.struts.action.ActionMapping) ServletActionContext(org.apache.struts.chain.contexts.ServletActionContext) ActionErrors(org.apache.struts.action.ActionErrors)

Aggregations

ActionMapping (org.apache.struts.action.ActionMapping)32 ActionForm (org.apache.struts.action.ActionForm)18 DynaActionForm (org.apache.struts.action.DynaActionForm)14 ActionForward (org.apache.struts.action.ActionForward)6 MockFormBean (org.apache.struts.mock.MockFormBean)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 ActionFormBean (org.apache.struts.action.ActionFormBean)4 ServletActionContext (org.apache.struts.chain.contexts.ServletActionContext)4 FormPropertyConfig (org.apache.struts.config.FormPropertyConfig)4 ForwardConfig (org.apache.struts.config.ForwardConfig)4 ModuleConfigFactory (org.apache.struts.config.ModuleConfigFactory)4 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Map (java.util.Map)2 ServletContext (javax.servlet.ServletContext)2 ServletException (javax.servlet.ServletException)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 JspException (javax.servlet.jsp.JspException)2 Field (org.apache.commons.validator.Field)2