Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Execute javascript if there is no validation error  RSS feed

 
ala alal
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a form with an a4j command button.
<a4j:commandButton/>

When I click the button it executes the validation of the form and if there is no validation error I would like to execute a javascript function.
How to do that? I tried with oncomplete property but it always executes the function also if there was a validation error.

Help?
 
Srini Mutpur
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Send the exception param or exception conditon to the oncomplete javascript function. Based on that execute the code in the script function.

Ex: <a4j:commandLink action="#{mybean.doActionMethod}" onComplete="executeScript('#{myBean.exception}');"/>

<script>
function executeScript(exception){

if(exception != null || exception != ''){

// java script code as per business needs

}

}
</script>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!