Struts 2
  1. Struts 2
  2. WW-2556

Ajax validation does not work in portlets.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.1.0
    • Fix Version/s: Future
    • Labels:
      None
    • Environment:

      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

        Issue Links

          Activity

          Hide
          Lukasz Lenart added a comment -

          Ajax validation is not supported

          Show
          Lukasz Lenart added a comment - Ajax validation is not supported
          Hide
          David Guillaume added a comment -

          Hi, can you tell me where is the resolution of this matter?
          I need to use ajax validation with struts2.

          Thanx for your reply

          Show
          David Guillaume added a comment - Hi, can you tell me where is the resolution of this matter? I need to use ajax validation with struts2. Thanx for your reply
          Hide
          Nils-Helge Garli added a comment -

          Reducing this to "major" as with the other ajax/portlet issues.

          Show
          Nils-Helge Garli added a comment - Reducing this to "major" as with the other ajax/portlet issues.
          Hide
          Nils-Helge Garli added a comment -

          Ajax in portlets are not supported by the framework. It has been discussed a couple of times already and you can find some background information if you search the mailing lists. The main problem is that a portlet only renders fragments, and the s:head tag which includes the required javascripts does so in a <head> tag. Also, there are challenges with namespacing of the id of html elements. However, it's possible to roll your own ajax stuff if you don't want to wait.

          Show
          Nils-Helge Garli added a comment - Ajax in portlets are not supported by the framework. It has been discussed a couple of times already and you can find some background information if you search the mailing lists. The main problem is that a portlet only renders fragments, and the s:head tag which includes the required javascripts does so in a <head> tag. Also, there are challenges with namespacing of the id of html elements. However, it's possible to roll your own ajax stuff if you don't want to wait.

            People

            • Assignee:
              Unassigned
              Reporter:
              Vladimir Limansky
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development