3 Replies Latest reply on Aug 3, 2009 3:46 AM by Ilya Shaikovsky

    a4j:jsFunction problem

    Ross Oreto Newbie

      Something is going wrong with the use of the <a4j:jsFunction> tag, I am using it as follows:

       <body onload="showInputGrid(); formatVersion(); return false;" >
       <f:loadBundle basename="message" var="msg"/>
       <h:form id="fngForm" style="width:auto;" >
      
       <h:outputText id="fngVersion" value="Version #{FNGFileNamesMasterFB.cvsVersion}" />
      
       <a4j:jsFunction id="formatVersionId" name="formatVersion" reRender="fngVersion" >
       <a4j:actionparam id="cvsVersionParam" assignTo="#{FNGFileNamesMasterFB.cvsVersion}"
       value="#{msg.cvsVersion}" />
       </a4j:jsFunction>
      ....
      


      The name formatVersion cannot be found when the onload javascript function formatVersion() is called. In firefox I get the js error message "formatVersion is not defined", although it clearly is defined in the tag. The same js error happens in IE although the message is different. Anyone have experience with this tag or know why the name cannot be found?


        • 1. Re: a4j:jsFunction problem
          Alexander Smirnov Master

          jsFunction renders JavaScript definition in the page body. The error seems like 'onload' event was called before page processing.

          • 2. Re: a4j:jsFunction problem
            Ross Oreto Newbie

            Thanks for your input.
            I moved the js call from the page onload to a onkeyup event on an inputText as follows:

            <body onload="showInputGrid(); return false;" >
             <f:loadBundle basename="message" var="msg"/>
             <h:form id="fngForm" style="width:auto;" >
            
             <h:outputText id="fngVersion" value="Version #{FNGFileNamesMasterFB.cvsVersion}" />
            
             <a4j:jsFunction id="formatVersionId" name="formatVersion" reRender="fngVersion" >
             <a4j:actionparam id="cvsVersionParam" assignTo="#{FNGFileNamesMasterFB.cvsVersion}"
             value="#{msg.cvsVersion}" />
             </a4j:jsFunction>
            
             <h:panelGroup id="limsSampleIDGroup">
             <h:inputText id="LIMSSampleID" required="false" onkeyup="formatVersion();"
             styleClass="input" value="#{FNGFileNamesMasterFB.limsSampleID}">
             </h:inputText>
             <h:outputText id="limsSampleIDMessage" styleClass="errorMessage"
             value="#{FNGFileNamesMasterFB.limsSampleIDError}"/><br />
             <h:outputText id="limsSampleIDDescription" value="#{msg.limsSampleIDDescription}" />
             </h:panelGroup>
            ...
            


            The same js error occurs now when I release a key from the inputText field.

            • 3. Re: a4j:jsFunction problem
              Ilya Shaikovsky Master

              you defined function with parameter and calling it without passing it. So error risen for me also. But it seems not a valid usage.