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

  • Home
  • SEARCH
  • 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 7912225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:32:47+00:00 2026-06-03T13:32:47+00:00

I need to set the id attribute of the html body -tag (for selenium

  • 0

I need to set the id attribute of the html body-tag (for selenium test). But that JSF 2 body tag (<h:body>) has no id attribute.

So, how can I specify the id attribute for the html body in JSF 2?

  • 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-03T13:32:48+00:00Added an answer on June 3, 2026 at 1:32 pm

    The <h:body> does indeed not support it (admittedly also to my surprise; it’s perfectly valid in HTML). I have reported it to the JSF guys as issue 2409.

    In the meanwhile, assuming that you’re using Mojarra, you could solve this by extending Mojarra’s BodyRenderer as follows:

    package com.example;
    
    import java.io.IOException;
    
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    
    import com.sun.faces.renderkit.html_basic.BodyRenderer;
    
    public class BodyWithIdRenderer extends BodyRenderer {
    
        @Override
        public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
            super.encodeBegin(context, component);
    
            if (component.getId() != null) {
                context.getResponseWriter().writeAttribute("id", component.getClientId(context), "id");
            }
        }
    
    }
    

    To get it to run, register it as follows in faces-config.xml (no, the @FacesRenderer annotation magic won’t work as to overriding the standard renderers).

    <render-kit>
        <renderer>
            <component-family>javax.faces.Output</component-family>
            <renderer-type>javax.faces.Body</renderer-type>
            <renderer-class>com.example.BodyWithIdRenderer</renderer-class>
        </renderer>
    </render-kit>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need: Find a way to add a valid tag/attribute/property to a normal html control.
I'm reading in a huge HTML string that has some info I need to
I need to set the ErrorMessage property of the DataAnnotation's validation attribute in MVC
I need to set the default icon that VS uses for the project to
I need to set the image height everytime I'm using background: url('images/something.jpg')[..]; Fe. HTML:
<%= Html.EditorFor(product => product.Name) %> I need the generated output to have autocomplete=off attribute
I've set ValidateInput attribute to false for actions that deal with posting comments. I'm
Need to set some attributes of button. For example Checked. I guess it is
Need set zoom for camera preview...
I need set a cultureinfo different of others in a currency field. Metadata: [Display(ResourceType

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.