Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-4636

Using f:param + f:ajax onvent results in an error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3-next-M8
    • 3.0.3, 4.0.2, 2.3-next-M9, 4.1.0-RC1, 5.0.0
    • None
    • None

    Description

      Steps to reproduce:

      • create xhtml with f:param and f:ajax onevent like this:

       

      <h:form prependId="false">
          <h:commandLink action="#{sampleBean.doAction}">
              <h:outputText value="Click Me!"/>
              <f:param name="var1" value="NEW VALUE"/>
              <f:ajax event="click"
                      execute="@this"
                      onevent="testJs">
              </f:ajax>
          </h:commandLink>
      </h:form>
      
      <script>
          //<![CDATA[
          function testJs(data) {
              if (data.status === 'success') {
                  alert("Success click")
              }
          }
          //]]>
      </script>
      

       

      • click on "Click me"
      • get an error in the console: "Uncaught SyntaxError: Unexpected token ':' (at index.xhtml:9:868)"

      The reason:

      Generated page code by M7 build:

      jsf.util.chain(this, event,function(event){myfaces.ab(this,event,'click','j_id_i','',{'onevent':testJs,'var1':'NEW VALUE'})}); return false;
      

      Generated page code by M8 build with bad JS (look at testJsparams):

      jsf.util.chain(this, event,function(event){myfaces.ab(this,event,'click','j_id_i','',{'onevent':testJsparams:{'var1':'NEW VALUE'}})}); return false;
      

      I've attached an archive with an example.

      Attachments

        1. sample.zip
          4 kB
          Vitaly Sidorov

        Activity

          People

            tandraschko Thomas Andraschko
            sidvi Vitaly Sidorov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: