Search in sources :

Example 61 with ForwardConfig

use of org.apache.struts.config.ForwardConfig in project sonar-java by SonarSource.

the class AbstractPerformForward method execute.

// ---------------------------------------------------------- Public Methods
/**
 * <p>Perform forwarding or redirection based on the specified
 * <code>ActionForward</code> (if any).</p>
 *
 * @param actionCtx The <code>Context</code> for the current request
 * @return <code>true</code> so that processing completes
 * @throws Exception if thrown by the <code>Action</code>
 */
public boolean execute(ActionContext actionCtx) throws Exception {
    // Is there a ForwardConfig to be performed?
    ForwardConfig forwardConfig = actionCtx.getForwardConfig();
    if (forwardConfig == null) {
        return (false);
    }
    // Perform the appropriate processing on this ActionForward
    perform(actionCtx, forwardConfig);
    return (true);
}
Also used : ForwardConfig(org.apache.struts.config.ForwardConfig)

Example 62 with ForwardConfig

use of org.apache.struts.config.ForwardConfig in project sonar-java by SonarSource.

the class AbstractSelectForward method execute.

// ---------------------------------------------------------- Public Methods
/**
 * <p>Select and cache the <code>ActionForward</code> for this
 * <code>ActionConfig</code> if specified.</p>
 *
 * @param actionCtx The <code>Context</code> for the current request
 * @return <code>false</code> so that processing continues
 * @throws Exception if thrown by the Action class
 */
public boolean execute(ActionContext actionCtx) throws Exception {
    // Skip processing if the current request is not valid
    Boolean valid = actionCtx.getFormValid();
    if ((valid == null) || !valid.booleanValue()) {
        return (false);
    }
    // Acquire configuration objects that we need
    ActionConfig actionConfig = actionCtx.getActionConfig();
    ModuleConfig moduleConfig = actionConfig.getModuleConfig();
    ForwardConfig forwardConfig = null;
    String forward = actionConfig.getForward();
    if (forward != null) {
        forwardConfig = forward(actionCtx, moduleConfig, forward);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Forwarding to " + forwardConfig);
        }
        actionCtx.setForwardConfig(forwardConfig);
    }
    return (false);
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig) ModuleConfig(org.apache.struts.config.ModuleConfig) ForwardConfig(org.apache.struts.config.ForwardConfig)

Example 63 with ForwardConfig

use of org.apache.struts.config.ForwardConfig in project sonar-java by SonarSource.

the class TagTestBase method setUp.

/**
 * Helper method that creates/configures a basic configuration of Mock
 * Objects.
 *
 * PageContext ServletConfig ServletContext HttpServletRequest HttpSession
 * HttpServletResponse
 *
 * "/myapp", "/foo", null, null,
 */
public void setUp() {
    // -- default Module
    this.moduleConfig = new ModuleConfigImpl("");
    this.moduleConfig.addForwardConfig(new ForwardConfig("foo", "/bar.jsp", false));
    this.moduleConfig.addForwardConfig(new ForwardConfig("relative1", "relative.jsp", false));
    this.moduleConfig.addForwardConfig(new ForwardConfig("relative2", "relative.jsp", false));
    this.moduleConfig.addForwardConfig(new ForwardConfig("external", "http://struts.apache.org/", false));
    // -- module "/2"
    this.moduleConfig2 = new ModuleConfigImpl("/2");
    this.moduleConfig2.addForwardConfig(new ForwardConfig("foo", "/baz.jsp", false));
    this.moduleConfig2.addForwardConfig(new ForwardConfig("relative1", "relative.jsp", false));
    this.moduleConfig2.addForwardConfig(new ForwardConfig("relative2", "relative.jsp", false));
    this.moduleConfig2.addForwardConfig(new ForwardConfig("external", "http://struts.apache.org/", false));
    // -- module "/3"
    this.moduleConfig3 = new ModuleConfigImpl("/3");
    // -- configure the ServletContext
    this.servletContext = new MockServletContext();
    this.servletContext.setAttribute(Globals.MODULE_KEY, moduleConfig);
    this.servletContext.setAttribute(Globals.MODULE_KEY + "/2", moduleConfig2);
    this.servletContext.setAttribute(Globals.MODULE_KEY + "/3", moduleConfig3);
    // -- configure the ServletConfig
    this.servletConfig = new MockServletConfig();
    this.servletConfig.setServletContext(servletContext);
    // -- configure the request
    this.request = new MockHttpServletRequest(new MockHttpSession());
    pageContext = new MockPageContext(servletConfig, request, new MockHttpServletResponse());
}
Also used : MockHttpServletRequest(org.apache.struts.mock.MockHttpServletRequest) MockServletConfig(org.apache.struts.mock.MockServletConfig) MockHttpSession(org.apache.struts.mock.MockHttpSession) MockPageContext(org.apache.struts.mock.MockPageContext) ForwardConfig(org.apache.struts.config.ForwardConfig) ModuleConfigImpl(org.apache.struts.config.impl.ModuleConfigImpl) MockServletContext(org.apache.struts.mock.MockServletContext) MockHttpServletResponse(org.apache.struts.mock.MockHttpServletResponse)

Aggregations

ForwardConfig (org.apache.struts.config.ForwardConfig)63 ActionConfig (org.apache.struts.config.ActionConfig)14 UnavailableException (javax.servlet.UnavailableException)12 ServletException (javax.servlet.ServletException)10 ExceptionConfig (org.apache.struts.config.ExceptionConfig)10 MalformedURLException (java.net.MalformedURLException)8 ModuleConfig (org.apache.struts.config.ModuleConfig)8 IOException (java.io.IOException)6 MissingResourceException (java.util.MissingResourceException)6 ModuleConfigFactory (org.apache.struts.config.ModuleConfigFactory)6 SAXException (org.xml.sax.SAXException)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 ActionFormBean (org.apache.struts.action.ActionFormBean)4 ActionForward (org.apache.struts.action.ActionForward)4 ActionMapping (org.apache.struts.action.ActionMapping)4 ActionServlet (org.apache.struts.action.ActionServlet)4 FormPropertyConfig (org.apache.struts.config.FormPropertyConfig)4 ServletActionContext (org.apache.struts.chain.contexts.ServletActionContext)3 ArrayList (java.util.ArrayList)2