Search in sources :

Example 71 with ActionConfig

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

the class AbstractExecuteAction method execute.

// ---------------------------------------------------------- Public Methods
/**
 * <p>Invoke the appropriate <code>Action</code> for this request, and
 * cache the returned <code>ActionForward</code>.</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 the resources we will need to send to the Action
    Action action = actionCtx.getAction();
    if (action == null) {
        return (false);
    }
    ActionConfig actionConfig = actionCtx.getActionConfig();
    ActionForm actionForm = actionCtx.getActionForm();
    // Execute the Action for this request, caching returned ActionForward
    ForwardConfig forwardConfig = execute(actionCtx, action, actionConfig, actionForm);
    actionCtx.setForwardConfig(forwardConfig);
    return (false);
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig) Action(org.apache.struts.action.Action) ActionForm(org.apache.struts.action.ActionForm) ForwardConfig(org.apache.struts.config.ForwardConfig)

Example 72 with ActionConfig

use of org.apache.struts.config.ActionConfig 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 73 with ActionConfig

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

the class TestTagUtils method testString_getActionMappingURL_String_String_PageContext_boolean1.

// use servlet mapping (extension mapping)
public void testString_getActionMappingURL_String_String_PageContext_boolean1() {
    pageContext.getServletContext().setAttribute(Globals.SERVLET_KEY, "*.do");
    ActionConfig actionConfig = new ActionConfig();
    actionConfig.setParameter("/foo");
    moduleConfig.addActionConfig(actionConfig);
    request.setAttribute(Globals.MODULE_KEY, moduleConfig);
    request.setPathElements("/myapp", "/baz.do", null, null);
    assertEquals("Check path /foo", tagutils.getActionMappingURL("/foo", pageContext), "/myapp/foo.do");
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig)

Example 74 with ActionConfig

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

the class TestTagUtils method testComputeURLCharacterEncodingAction.

public void testComputeURLCharacterEncodingAction() {
    ActionConfig actionConfig = new ActionConfig();
    actionConfig.setName("baz");
    actionConfig.setPath("/baz");
    moduleConfig.addActionConfig(actionConfig);
    request.setPathElements("/myapp", "/foo.do", null, null);
    Map map = new HashMap();
    map.put("foo1", "bar1");
    map.put("foo2", "bar2");
    String url = null;
    try {
        url = tagutils.computeURL(pageContext, null, null, null, "baz", null, map, "anchor", false);
    } catch (MalformedURLException e) {
        fail("MalformedURLException: " + e);
    }
    assertNotNull("url present", url);
    assertTrue("url value", url.equals("/myapp/baz?foo1=bar1&amp;foo2=bar2#anchor") || url.equals("/myapp/baz?foo2=bar2&amp;foo1=bar1#anchor"));
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig) MalformedURLException(java.net.MalformedURLException) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 75 with ActionConfig

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

the class TestTagUtils method testString_getActionMappingURL_String_String_PageContext_boolean3.

// use servlet mapping (extension mapping)
// -- path as "/"
// (this is probably not a realistic use case)
public void testString_getActionMappingURL_String_String_PageContext_boolean3() {
    pageContext.getServletContext().setAttribute(Globals.SERVLET_KEY, "*.do");
    ActionConfig actionConfig = new ActionConfig();
    actionConfig.setParameter("/foo");
    moduleConfig.addActionConfig(actionConfig);
    request.setAttribute(Globals.MODULE_KEY, moduleConfig);
    request.setPathElements("/mycontext", "/baz", null, null);
    assertEquals("Check path /foo", tagutils.getActionMappingURL("/", pageContext), "/mycontext/.do");
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig)

Aggregations

ActionConfig (org.apache.struts.config.ActionConfig)76 ForwardConfig (org.apache.struts.config.ForwardConfig)14 UnavailableException (javax.servlet.UnavailableException)8 ActionForm (org.apache.struts.action.ActionForm)8 ExceptionConfig (org.apache.struts.config.ExceptionConfig)8 FormBeanConfig (org.apache.struts.config.FormBeanConfig)8 ModuleConfig (org.apache.struts.config.ModuleConfig)8 ServletException (javax.servlet.ServletException)6 MalformedURLException (java.net.MalformedURLException)4 Map (java.util.Map)4 Action (org.apache.struts.action.Action)4 UnauthorizedActionException (org.apache.struts.chain.commands.UnauthorizedActionException)4 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 MissingResourceException (java.util.MissingResourceException)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 JspException (javax.servlet.jsp.JspException)2 ActionErrors (org.apache.struts.action.ActionErrors)2 MockActionContext (org.apache.struts.chain.contexts.MockActionContext)2 ServletActionContext (org.apache.struts.chain.contexts.ServletActionContext)2