I have a use case where I need to play a warning sound if user submits an invalid product number. I can use the SoundManager2 JavaScript api to play the sound. But how can I call the JavaScript function based on a value in my managed bean? What I want to do is attach an action to a command button that calls a method on the backing bean to validate the product number. If the validation fails then I need to call the JavaScript function that plays the warning sound. Sounds simple enough, but how to bridge the apparent gap beteween client side JavaScript and server side bean? Maybe a whole different approach would work better. Any ideas?
pay attention on 'data' attribute of any Ajax Component (a4j:support, a4j:commandButton, a4j:jsFunction and so on). It might returns data that you can use then in the oncomplete javascript hookup.