Including scripts in JSF 2 Ajax requests
So, go and follow the link, but I’ll just add three short comments to Hazem’s blog:
- In many popular ajax solutions for JSF, <script> tags were simply interpreted in place. This is not, for whatever reason, part of the JSF spec right now – so you’ll have to use one of the two ways that Hazem describes, in order for it to be a portable solution.
- The first solution Hazem notes uses the event system for JSF client side – it simply adds an event listener that’s called every time a page is updated, and calls the eval for any included scripts.
- The second solution is the “preferred” way that is specified in the spec – simply return the script you want to execute as part of the xml that goes to the client.
Hope this note helps someone trying to execute an arbitrary script on a JSF client page.
(This article originally published on my java.net blog on July 18, 2009.)