Search in sources :

Example 11 with DynaActionForm

use of org.apache.struts.action.DynaActionForm in project iaf by ibissource.

the class ActionBase method execute.

/**
 * This proc should start with <code>initAction(request)</code>
 * @see Action
 */
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    if (isWriteToSecLog()) {
        if (secLogMessage && isWriteSecLogMessage()) {
            DynaActionForm dynaActionForm = (DynaActionForm) form;
            String form_message = null;
            try {
                form_message = (String) dynaActionForm.get("message");
            } catch (IllegalArgumentException e) {
                try {
                    form_message = (String) dynaActionForm.get("query");
                } catch (IllegalArgumentException e2) {
                    form_message = "could not derive message or query from DynaForm";
                }
            }
            secLog.info(HttpUtils.getExtendedCommandIssuedBy(request, secLogParamNames, form_message));
        } else {
            secLog.info(HttpUtils.getExtendedCommandIssuedBy(request, secLogParamNames));
        }
    }
    return executeSub(mapping, form, request, response);
}
Also used : DynaActionForm(org.apache.struts.action.DynaActionForm)

Example 12 with DynaActionForm

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

the class TestRequestUtils method testCreateActionForm3a.

// Default module -- Dynamic ActionForm should be created
public void testCreateActionForm3a() {
    request.setPathElements("/myapp", "/dynamic.do", null, null);
    ActionMapping mapping = (ActionMapping) moduleConfig.findActionConfig("/dynamic");
    assertNotNull("Found /dynamic mapping", mapping);
    assertNotNull("Mapping has non-null name", mapping.getName());
    assertEquals("Mapping has correct name", "dynamic", mapping.getName());
    assertNotNull("AppConfig has form bean " + mapping.getName(), moduleConfig.findFormBeanConfig(mapping.getName()));
    ActionForm form = RequestUtils.createActionForm(request, mapping, moduleConfig, null);
    assertNotNull("ActionForm returned", form);
    assertTrue("ActionForm of correct type", form instanceof DynaActionForm);
}
Also used : ActionMapping(org.apache.struts.action.ActionMapping) DynaActionForm(org.apache.struts.action.DynaActionForm) ActionForm(org.apache.struts.action.ActionForm) DynaActionForm(org.apache.struts.action.DynaActionForm)

Example 13 with DynaActionForm

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

the class TestRequestUtils method testCreateActionForm3b.

// Second module -- Dynamic ActionForm should be created
public void testCreateActionForm3b() {
    request.setPathElements("/myapp", "/2/dynamic2.do", null, null);
    ActionMapping mapping = (ActionMapping) moduleConfig2.findActionConfig("/dynamic2");
    assertNotNull("Found /dynamic2 mapping", mapping);
    assertNotNull("Mapping has non-null name", mapping.getName());
    assertEquals("Mapping has correct name", "dynamic2", mapping.getName());
    assertNotNull("AppConfig has form bean " + mapping.getName(), moduleConfig2.findFormBeanConfig(mapping.getName()));
    ActionForm form = RequestUtils.createActionForm(request, mapping, moduleConfig2, null);
    assertNotNull("ActionForm returned", form);
    assertTrue("ActionForm of correct type", form instanceof DynaActionForm);
}
Also used : ActionMapping(org.apache.struts.action.ActionMapping) DynaActionForm(org.apache.struts.action.DynaActionForm) ActionForm(org.apache.struts.action.ActionForm) DynaActionForm(org.apache.struts.action.DynaActionForm)

Example 14 with DynaActionForm

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

the class TestCopyFormToContext method testLookupByNameAndSessionScope.

public void testLookupByNameAndSessionScope() throws Exception {
    CopyFormToContext command = new CopyFormToContext();
    String formName = "bar";
    command.setFormName(formName);
    command.setScope("session");
    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));
    assertNull(context.getRequestScope().get(formName));
    assertNotNull(context.getSessionScope().get(formName));
    assertSame(context.get(POST_EXECUTION_CONTEXT_KEY), context.getSessionScope().get(formName));
    ActionForm theForm = (ActionForm) context.get(POST_EXECUTION_CONTEXT_KEY);
    assertTrue(theForm instanceof DynaActionForm);
    DynaActionForm dForm = (DynaActionForm) theForm;
    assertEquals("test", dForm.get("property"));
}
Also used : DynaActionForm(org.apache.struts.action.DynaActionForm) ActionForm(org.apache.struts.action.ActionForm) DynaActionForm(org.apache.struts.action.DynaActionForm)

Example 15 with DynaActionForm

use of org.apache.struts.action.DynaActionForm in project sonarqube by SonarSource.

the class TestRequestUtils method testCreateActionForm3b.

// Second module -- Dynamic ActionForm should be created
public void testCreateActionForm3b() {
    request.setPathElements("/myapp", "/2/dynamic2.do", null, null);
    ActionMapping mapping = (ActionMapping) moduleConfig2.findActionConfig("/dynamic2");
    assertNotNull("Found /dynamic2 mapping", mapping);
    assertNotNull("Mapping has non-null name", mapping.getName());
    assertEquals("Mapping has correct name", "dynamic2", mapping.getName());
    assertNotNull("AppConfig has form bean " + mapping.getName(), moduleConfig2.findFormBeanConfig(mapping.getName()));
    ActionForm form = RequestUtils.createActionForm(request, mapping, moduleConfig2, null);
    assertNotNull("ActionForm returned", form);
    assertTrue("ActionForm of correct type", form instanceof DynaActionForm);
}
Also used : ActionMapping(org.apache.struts.action.ActionMapping) DynaActionForm(org.apache.struts.action.DynaActionForm) ActionForm(org.apache.struts.action.ActionForm) DynaActionForm(org.apache.struts.action.DynaActionForm)

Aggregations

DynaActionForm (org.apache.struts.action.DynaActionForm)20 ActionForm (org.apache.struts.action.ActionForm)8 ActionMapping (org.apache.struts.action.ActionMapping)6 IOException (java.io.IOException)5 ServletException (javax.servlet.ServletException)5 ActionForward (org.apache.struts.action.ActionForward)4 ArrayList (java.util.ArrayList)3 Cookie (javax.servlet.http.Cookie)3 StringTagger (nl.nn.adapterframework.util.StringTagger)3 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 List (java.util.List)2 IbisAppenderWrapper (nl.nn.adapterframework.extensions.log4j.IbisAppenderWrapper)2 XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)2 Appender (org.apache.log4j.Appender)2 Logger (org.apache.log4j.Logger)2 MockPrincipal (org.apache.struts.mock.MockPrincipal)2 FormFile (org.apache.struts.upload.FormFile)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 PrintWriter (java.io.PrintWriter)1