6 Replies Latest reply on Dec 17, 2009 8:04 AM by user1234

    Problem with onclick attribute of a4j:htmlCommandLink

      Hi,

         We have been facing a problem with the onclick attribute of the a4j:htmlCommandLink.

       

      Environment: Facelets 1.1.4, RichFaces 3.1.4 GA, Java 5

       

      The code that we have in the xhtml file is

       

      <

       

      a4j:htmlCommandLink value="#{msg.some_value}" action="#{myBean.doProcess}" immediate="true" onclick="clickMe();"/>

       

      Strangely, the above line is rendered in two different ways and they occur at random.

       

      This first statement below works on IE and Firefox and the action is invoked:

       

      <a id="newModalForm:j_id188"  href="#" onclick="clickMe();;return _JSFFormSubmit('newModalForm:j_id188','newModalForm',null,{'newModalForm:_idcl':'newModalForm:j_id188'} )">My Link</a>

       

       

       

       

      This second statement does not invoke the action on IE or Firefox due to the extra onclick attribute added:

       

      <a id="newModalForm:j_id188" onclick="clickMe();" href="#" onclick="clickMe();;return _JSFFormSubmit('newModalForm:j_id188','newModalForm',null,{'newModalForm:_idcl':'newModalForm:j_id188'} )">My Link</a>

       

      I tried debugging the code and I found that this 'onclick' string is being built in the encodePassThruWithExclusionsArray method of the RendererUtils class and it is being invoked from the doEncodeActiveBegin method of the HtmlCommandLinkRenderer class. The LINK_EXCLUSIONS array contains a "onclick" element and I am unable to understand how the extra onclick attribute is rendered in the output html.

       

      Surprisingly, this problem does not occur always and it occurs randomly. Could this be somehow related to the JSF component tree?

       

      Can you please let me know if I am on the right track and any pointers/suggestions to troubleshoot this problem will be extremely helpful. Please let me know if I should share any other information.

       

      Thanks & Regards,

      Bala