1 Reply Latest reply on Dec 24, 2008 5:34 AM by ilya_shaikovsky

    a4j commandlink onclick event

    cchidamb

      Hi,
      I'm using <a4j:commandLink reRender="ipTable, ip_panel" action="#{inventoryHome.addAnotherIP}"
      value="#{messages.action_add}" onclick="return isValidIPAddress('ipFirstOctet', 'ipSecondOctet', 'ipThirdOctet', 'ipFourthOctet', '#{messages.ValidIP}')">
      </a4j:commandLink>

      It doesn't matter what the return value from the javascript API commandLink is not firing the request. If I specify like this i.e. without calling return in the onclick it fires the request, but I want the request to be fired only if the javascript method returns true.

      <a4j:commandLink reRender="ipTable, ip_panel" action="#{inventoryHome.addAnotherIP}"
      value="#{messages.action_add}" onclick="isValidIPAddress('ipFirstOctet', 'ipSecondOctet', 'ipThirdOctet', 'ipFourthOctet', '#{messages.ValidIP}')">
      </a4j:commandLink>

        • 1. Re: a4j commandlink onclick event
          ilya_shaikovsky

          So just call return false only if condition is false and do not return anything if not. return breaks Ajax request because the request actually called by JS function call placed after your one. So it will not be called if you return anything.

          Works as designed.