MyFaces Core
  1. MyFaces Core
  2. MYFACES-3460

onsubmit of form not executed for ajax commands

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.8, 2.1.5
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Tomcat 6.0.32, Facelets

      Description

      During the migration from JSF 1.2 to 2.1 I noticed that the onsubmit attribute of forms is not executed for ajax links.

      Sample:

      <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
      <ui:composition>

      <h:form id="myform" onsubmit="alert('submitted')" >
      <h:outputText id="oldCounter" value="oldCounter: #

      {MyController.counter}"/><br/>
      <h:outputText id="newCounter" value="newCounter: #{MyController.counter}

      "/><br/>

      <h:commandButton value="AjaxButton" actionListener="#

      {MyController.increase}" >
      <f:ajax render="newCounter" execute="@this"/>
      </h:commandButton><br/>
      <h:commandButton value="Button" actionListener="#{MyController.increase}

      "/>
      </h:form>

      </ui:composition>
      </html>

      @ManagedBean(name = "MyController")
      @SessionScoped
      public class MyController{
      private int counter = 1;
      public int getCounter()

      { return counter; }

      public void increase(ActionEvent ae)

      { counter++; }

      }

      This is also not working with mojarra 2.1.6 and 2.0.8.

      I used the onsbumit with JSF 1.2 in order to lock the screen and prevent double submits.
      Now I do not see any working alternative in JSF 2.1

        Activity

        Hide
        Werner Punz added a comment -

        Not directly a bug, as I explained in the users list, onsubmit is not performed because no direct form submit is performed at all. For intercepting ajax calls there is the event listener interface.
        Ajax Double submits can be prevented in myfaces at least with the queue control functionality, see this article here for further info:
        http://www.irian.at/de/blog/-/blogs/apache-myfaces-queue-control

        The delay functionality is exactly what can be used for double ajax submit prevention within a certain timeframe.
        outside of that you can use the ajax listener functionality to prevent double submits for infinite submit time by throwing an error in case of a double submit.

        Show
        Werner Punz added a comment - Not directly a bug, as I explained in the users list, onsubmit is not performed because no direct form submit is performed at all. For intercepting ajax calls there is the event listener interface. Ajax Double submits can be prevented in myfaces at least with the queue control functionality, see this article here for further info: http://www.irian.at/de/blog/-/blogs/apache-myfaces-queue-control The delay functionality is exactly what can be used for double ajax submit prevention within a certain timeframe. outside of that you can use the ajax listener functionality to prevent double submits for infinite submit time by throwing an error in case of a double submit.
        Hide
        Werner Punz added a comment -

        I will leave this bug open because it raises the issue of how to cancel a request indirectly. I will file the cancel a request properly issue with the EG and then close the bug.

        Show
        Werner Punz added a comment - I will leave this bug open because it raises the issue of how to cancel a request indirectly. I will file the cancel a request properly issue with the EG and then close the bug.

          People

          • Assignee:
            Werner Punz
            Reporter:
            Michael Heinen
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development