2 Replies Latest reply on May 2, 2007 1:56 PM by Sergey Smirnov

    a4j:commandLink onclick return value affects behaviour

    Markus Kühle Newbie


      it seems that the return value of any javascript function which is called in onclick attribute of a4j:commandLink does stop the ajax call.

      In my case i need a user confirmation if user clicks on an a4j:commandLink. If the user cancel the confirmation the ajax call shouldn't be performed. If the user pushes 'OK' the confirmation dialog returns true and the a4j:commandLink should perfom the ajax call but it doesn't.

      The following code

      <a4j:commandLink action="#{MyBB.doit}" reRender="myComp" onclick="return confirm('Confirm it');">Delete Entry</a4j:commandLink>

      It doesn't matter wich case the confirmation returns ('OK' -> true or 'Cancel' -> false) the a4j:commandLink doesn't perform the ajax call.

      But also if onclick="return true;" is set the ajax call wouldn't be perfomed.

      I would expect that 'return true' will perform the normal behaviour. My question is: how can i implement a user confirmation for this component?

      In this example the ajax call to delete an entry should only be performed if the user will confirm this action.
      Thanks for any suggestions.