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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:45:37+00:00 2026-06-04T09:45:37+00:00

Can someone who is an active JSF (or Primefaces) user explain why by default

  • 0

Can someone who is an active JSF (or Primefaces) user explain why by default this happens why nobody is doing anything about it:

<p:commandLink id="baz" update=":foo:boop" value="Example" />

Which generates markup that cannot be used in JavaScript or CSS without hacks and should generally be considered invalid:

<a href="javascript:void(0);" id=":foo:bar:baz">Example</a>

The id=":bar:baz:foo" attribute here contains colons, which aren’t a valid character for this attribute, at least from CSS perspective.

While the attribute may be valid according to spec, it fails to work with real-world JavaScript and CSS implementations.

In short, default id attribute generation in JSF is unusable for front-end development.

  • 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-04T09:45:38+00:00Added an answer on June 4, 2026 at 9:45 am

    The : is been chosen because that’s the only sensible separator character for which can be guaranteed that the enduser won’t accidently use it in JSF component IDs (which is been validated) and that it’s possible to use it in CSS selectors by escaping it with \.

    Note that the HTML4 spec says that the colon is a valid value in id and name attribute. So your complaint that it isn’t compatible with "web standards" goes nowhere.

    ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

    The only problem is thus that the : is a special character in CSS selectors which needs to be escaped. JS has at its own no problems with colons. The document.getElementById("foo:bar") works perfectly fine. The only possible problem is in jQuery because it uses CSS selector syntax.

    If you really need to, then you can always change the default separator character : by setting the javax.faces.SEPARATOR_CHAR context param to e.g. - or _ as below. You only need to guarantee that you don’t use that character anywhere in JSF component IDs yourself (it’s not been validated!).

    <context-param>
        <param-name>javax.faces.SEPARATOR_CHAR</param-name>
        <param-value>-</param-value>
    </context-param>
    

    The _ has by the way the additional disadvantage that it occurs in JSF autogenerated IDs like j_id1, thus you should also ensure that all NamingContainer components throughout your JSF pages have a fixed ID instead of an autogenerated one. Otherwise JSF will have problems finding naming container children.

    I would only not recommend it. It’s in long term confusing and brittle. To think about it again, unique elements in the average JSF webapp are by itself usually already not inside forms or tables. They generally just represent the main layout aspects. I’d say, it’s otherwise a bad design in general HTML/CSS perspective. Just select them by reusable CSS class names instead of IDs. If you really need to, you can always wrap it in a plain HTML <div> or <span> whose ID won’t be prepended by JSF.

    See also:

    • What are valid values for the id attribute in HTML?
    • Is it possible to change the element id separator in JSF?
    • How to select JSF components using jQuery?
    • How to use JSF generated HTML element ID with colon ":" in CSS selectors?
    • Integrate JavaScript in JSF composite component, the clean way
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone who is way smarter than I tell me what I'm doing wrong..
Can someone explain to me this odd thing: When in python shell I type
Can someone who is a master at JS tell me what's wrong with this?
I know a little about SQL injections and URL decode, but can someone who's
I would appreciate if there is someone who can help me solve this problem,
I hope there's someone who can help me suggest a suitable data model to
Can someone explain it succinctly? Can it be used with non-Silverlight clients?
Can someone tell me why this processes all the files and then does it
I dropped out of the CS program at my university... So, can someone who
Is there someone who can strictly give me what is the job (DBMS_JOB) and

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.