0

I have simple JSF form and onclick event inside submit button (google analytics event tracking). Is it posible to somehow disable onclick event when jsf validation fails?

1 Answer 1

1

That's not possible. The onclick is fired before the request is sent to server. You basically want to fire it after the response has returned with a successful outcome.

There are several ways to achieve this:

  • Perform validation in JavaScript instead (not recommended).

  • Send tracking request from inside JSF bean's action method instead.

  • Send tracking request inside a (conditionally rendered) <script> element on result page instead.

Sign up to request clarification or add additional context in comments.

2 Comments

Can you say more about 2? Is it possible to run javascript inside JSF method?!?
No, that is what I meant with 3. With 2 I just meant to use Java instead of JavaScript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.