Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6144161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:36:46+00:00 2026-05-23T18:36:46+00:00

Whats the easiest way to toggle the rendering of a JSF Component based on

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:36:46+00:00Added an answer on May 23, 2026 at 6:36 pm

    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 click event on a hidden commandButton. 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 PrimeFaces p:commandButton with update attribute to do partial update.

    1. Have hidden form on your page with a inputText and a p:commandButton
    2. Determine if user is HTML5 enable using javascript, then invoke a click event on the commandButton. The inputText is there so that you can pass a flag back to the server.

    For example:

    <h:form style="display:none">
        <h:inputText id="flag" value="#{myBean.flag}"/>
        <p:commandButton id="button" actionListener="#{myBean.process}" update="..."/>
    </h:form>
    

    so your jQuery would look like this

     if(user is HTML5 enabled){
          jQuery("#flag").val("Flag that let you know user has HTML5 enable.")
          jQuery("#button").click();
     }else{
         //Same thing as above but passing a flag that you know user dont have HTML5 enabled
     }
    

    In your managed bean you would have

    @ManagedBean
    @RequestScoped
    public class MyBean{
        private String flag;
        private boolean display;
        //setter and getter for `flag` and `display`
    
        public void process(){
            if(flag.equals("HTML5")){
                display = true;
            }else{
                display = false;
            }
        }
    }    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whats the easiest way in javascript to replace ABC, DEF, GHI with XYZ in
Whats the easiest way to traverse a methodinfo in c#? I want to traverse
Whats the easiest way to find out what programming language an application was written
In TFS whats the easiest way of linking a backlog item to a large
Whats the best/easiest way to obtain a count of items within an IEnumerable collection
What is the easiest way to change the background color of a toggle button
Whats the easiest way to build a simple 'web' application which is a single
Whats the easiest way to clear an asp.net form at runtime using c#. Thanks
Whats the easiest way of stopping spammers from probing your forms (preferably without deterring
Whats the easiest way to strip the HTML tags in perl. I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.