Whats the easiest way to toggle the rendering of a JSF Component based on a javascript flag?
I want to display certain things based on whether the user has HTML5 enabled…e.g. geolocation, native date picker etc.
Thanks,D
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This answer assume that you know how to use javascript to check if the user has HTML5 enabled. Here is the idea. The one way for javascript to communicate with JSF server managed bean is to have the javascript invoke a
clickevent on a hiddencommandButton. So here is how you do it. This command button can then invoke function on your backing bean, like set a flag for display certain component on your page. For ajax request, you can use PrimeFacesp:commandButtonwithupdateattribute to do partial update.inputTextand ap:commandButtoncommandButton. TheinputTextis there so that you can pass a flag back to the server.For example:
so your jQuery would look like this
In your managed bean you would have