Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-2556

Ajax validation does not work in portlets.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 2.1.0
    • None
    • None
    • Struts 2.0.1 struts2-portlet-plugin struts2-dojo-plugin-2.1.0 xwork-2.1.0

    Description

      Consider the following configuration.

      1. EditTest.jsp:
      <sx:head/>

      <s:form action="Test!save" theme="xhtml" id="myFormId" >

      <s:textfield name="testProperty" label="test input"></s:textfield>

      <s:hidden name="testAction" value=""/>

      <sx:submit
      validate="true"
      ajaxAfterValidation="true"
      targets="response"
      showLoadingText="false"
      label="Submit it!"
      formId="myFormId"/>

      </s:form>

      2. TestAction.java

      public class TestAction extends BaseActionSupport {

      private String testProperty = null;

      @Override
      public String render() throws Exception

      { return SUCCESS; }

      @Transactional
      public String save()

      { return NONE; }

      public String getTestProperty()

      { return testProperty; }

      public void setTestProperty(String testProperty)

      { this.testProperty = testProperty; }

      }

      3. TestAction-validation.xml
      <validators>
      <field name="testProperty">
      <field-validator type="requiredstring">
      <message key="calendar:TitleIsRequired"/>
      </field-validator>
      </field>
      </validators>

      4. struts.xml
      <struts>
      <include file="struts-default.xml"/>
      <include file="struts-portlet-default.xml"/>
      <include file="sibutu-default.xml"/>

      <package name="calendar" extends="sibutu-default">

      <action name="Test" class="org.sibutu.module.calendar.action.TestAction">
      <interceptor-ref name="jsonValidationWorkflowStack"/>
      <result>/WEB-INF/jsp/Test.jsp</result>
      <result name="input">/WEB-INF/jsp/EditTest.jsp</result>
      <result name="none">/WEB-INF/jsp/Test.jsp</result>
      </action>

      </package>

      </struts>

      Currently I have the following behavior:
      1. The expected error message appears just emmidiately on the page startup, NOT after submit button had been pushed.
      2. When submit button had been pressed error message disappears - even if we assume that validation fails (the field was left blank with "requiredstring" validator).
      3. http://struts.apache.org/2.x/docs/ajax-validation.html says the following:
      "Remember to set struts.enableJSONValidation=true in the request to enable AJAX validation"
      But trying to debug JSONValidationInterceptor I noticed that struts.enableJSONValidation parameter is null. Where this parameter should be set? An attempt to put it to struts.properties gives nothing. But even when I tried to set this parameter manually during debug session, it did not cause the desired result.

      In the struts2-showcase-2.1.0.war struts example validation works pretty fine.

      Please let me know whether you need any additional info.

      Please

      Attachments

        Issue Links

          Activity

            People

              lukaszlenart Lukasz Lenart
              vlimansky Vladimir Limansky
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: