Two ways of triggering the JavaScript execution

The RequestContext utility class provides an easy way to execute any JavaScript code after the current AJAX request completes. The JavaScript block has to be coded in Java and can be executed by passing it to the execute() method. An alternative approach would be to update a script block on a page and trigger the script execution manually. In this case, the JavaScript block is coded directly into a page.

In this recipe, we will see both solutions for JavaScript execution. For this purpose, we will develop a menu component and toggle the enabling/disabling of menu items with two command buttons. The first command button should toggle enabling/disabling with the server-side approach and the second one ...

Get PrimeFaces Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.