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 8573679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:18:23+00:00 2026-06-11T19:18:23+00:00

We are starting to develop with PrimeFaces 3.4, JSF 2.0 and Tomcat 7.0. We

  • 0

We are starting to develop with PrimeFaces 3.4, JSF 2.0 and Tomcat 7.0. We are facing the problem that when we make a form page, we can navigate with the tab button on all the PrimeFaces input components, expect of <p:selectBooleanButton>. For example,

<h:form id="formId">
    <p:inputText id="inputId1" />
    <p:inputText id="inputId2" />
    <p:selectBooleanButton id="buttonId" onLabel="Yes" offLabel="No" />
    <p:inputText id="inputId3" />
    <p:inputText id="inputId4" />
</h:form>

Pressing tab in inputId2 goes directly to inputId3. Is this the expected behaviour? Is there any workaround?

  • 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-06-11T19:18:24+00:00Added an answer on June 11, 2026 at 7:18 pm

    It’s because of the way how the checkbox representing the state of <p:selectBooleanButton> was actually rendered by PrimeFaces SelectBooleanButtonRenderer:

    <div id="formId:buttonId" type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only">
        <input id="formId:buttonId_input" name="formId:buttonId_input" type="checkbox" class="ui-helper-hidden">
        <span class="ui-button-text">no</span>
    </div>
    

    The checkbox is completely hidden by the CSS display:none property in .ui-helper-hidden class and can thus never receive focus.

    If we look at the checkbox counterpart <p:selectBooleanCheckbox>, which also replaces the checkbox by a visually more appealing widget which is actually focusable, then we see that the checkbox isn’t completely hidden by CSS, but just made invisible by being wrapped in a <div> which is absolutely positioned by CSS position:absolute in .ui-helper-hidden-accessible class and is thus just overlayed by the checkbox widget:

    <div id="formId:checkboxId" class="ui-chkbox ui-widget">
        <div class="ui-helper-hidden-accessible">
            <input id="formId:checkboxId_input" name="formId:checkboxId_input" type="checkbox">
        </div>
        <div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default">
            <span class="ui-chkbox-icon"></span>
        </div>
    </div>
    

    I wouldn’t consider the <p:selectBooleanButton> being unfocusable “expected” or “intuitive” behaviour and if I were you, I’d surely report this UX matter to PrimeFaces.


    In the meanwhile, your best bet to workaround this is to create a custom renderer which overrides the encodeMarkup() method of the PrimeFaces SelectBooleanButtonRenderer as follows in order to remove the class="ui-helper-hidden" from the checkbox and wrap it in a <div class="ui-helper-hidden-accessible>, exactly as <p:selectBooleanCheckbox> is doing:

    public class MySelectBooleanButtonRenderer extends SelectBooleanButtonRenderer {
    
        @Override
        protected void encodeMarkup(FacesContext context, SelectBooleanButton button) throws IOException {
            ResponseWriter writer = context.getResponseWriter();
            String clientId = button.getClientId(context);
            boolean checked = Boolean.valueOf(ComponentUtils.getValueToRender(context, button));
            boolean disabled = button.isDisabled();
            String inputId = clientId + "_input";
            String label = checked ? button.getOnLabel() : button.getOffLabel();
            String icon = checked ? button.getOnIcon() : button.getOffIcon();
    
            //button
            writer.startElement("div", null);
            writer.writeAttribute("id", clientId, "id");
            writer.writeAttribute("type", "button", null);
            writer.writeAttribute("class", button.resolveStyleClass(checked, disabled), null);
            if(disabled) writer.writeAttribute("disabled", "disabled", null);
            if(button.getTitle()!= null) writer.writeAttribute("title", button.getTitle(), null);
            if(button.getStyle() != null) writer.writeAttribute("style", button.getStyle(), "style");
    
            //input
            writer.startElement("div", null); // <-- Added.
            writer.writeAttribute("class", "ui-helper-hidden-accessible", null); // <-- Added.
            writer.startElement("input", null);
            writer.writeAttribute("id", inputId, "id");
            writer.writeAttribute("name", inputId, null);
            writer.writeAttribute("type", "checkbox", null);
            // writer.writeAttribute("class", "ui-helper-hidden", null); <-- Removed.
    
            if(checked) writer.writeAttribute("checked", "checked", null);
            if(disabled) writer.writeAttribute("disabled", "disabled", null);
            if(button.getOnchange() != null) writer.writeAttribute("onchange", button.getOnchange(), null);
    
            writer.endElement("input");
            writer.endElement("div"); // <-- Added.
    
            //icon
            if(icon != null) {
                writer.startElement("span", null);
                writer.writeAttribute("class", HTML.BUTTON_LEFT_ICON_CLASS + " " + icon, null);
                writer.endElement("span");
            }
    
            //label
            writer.startElement("span", null);
            writer.writeAttribute("class", HTML.BUTTON_TEXT_CLASS, null);
            writer.writeText(label, "value");
            writer.endElement("span");
    
            writer.endElement("div");
        }
    
    }
    

    (look at the //input section, I have added <-- comments to explain which lines I’ve added/removed to the original source code which is been copypasted)

    To get it to run, register it as follows in faces-config.xml:

    <render-kit>
        <renderer>
            <component-family>org.primefaces.component</component-family>
            <renderer-type>org.primefaces.component.SelectBooleanButtonRenderer</renderer-type>
            <renderer-class>com.example.MySelectBooleanButtonRenderer</renderer-class>
        </renderer>
    </render-kit>
    

    (the component-family and renderer-type values are extracted from SelectBooleanButton component)

    This works for me, well, kind of. The <p:selectBooleanButton> gets focus and you can use the spacebar to toggle the boolean state. However, the focus isn’t visually visible in any way. This needs to be solved in the JavaScript side. The <div class="ui-button"> representing the button should get an .ui-state-focus class when the hidden checkbox gets focus. The following piece of jQuery achieves that:

    $(".ui-button input[type=checkbox]").focus(function() {
        $(this).closest(".ui-button").addClass("ui-state-focus");
    }).blur(function() {
        $(this).closest(".ui-button").removeClass("ui-state-focus");
    });
    

    Now it totally works for me.

    In real PrimeFaces source code this should be solved in init() function of the PrimeFaces.widget.SelectBooleanButton function of the forms.js file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm starting to develop applications for android, but I can not draw advanced interfaces
I am starting to develop an Android app and I have seen that in
I'm starting to develop a new ASP.NET MVC application, and I'd like to make
I'm starting to develop an application that involves dealing with recording audio. I'm using
I'm starting to develop a mobile version of a website that we run. Our
I'm using VS2008 to develop a project that I'm starting to test under Mono.
I'm starting to develop some multi-thread plataform to a project that allready exists (a
I am starting to redesign and develop a site that contains a lot of
I am starting to develop a Shopify integration. The app that I am trying
I am starting to develop apps for iPhone. There is 1 specific app that

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.