Search code examples
ajaxjsfactionabort

best practice to abort action method


what is the best apporach to abort a running action method in JSF?

e.g. I have an action, which performs some complicated DB operations and then returns the result site (e.g. "complete.xhtml").

How can I abort the running action-method (and do e.g. rollbacks?). maybe with ajax?

Thanks!


Solution

  • Well the usual approach is to use actionListener and action together.

    When button is clicked the actionListener will get called first.

    Check for your condition/validation at actionListener and if it doesn't match, then throw javax.faces.event.AbortProcessingException then your action method will not get called.

    Link