I don't like the way JSF uses a colon to separate the identifier in the generated HTML, as it interferes with CSS and JavaScript Selectors. And I do not like the idea of always avoiding this.
Just select items by class name then? Is the nature of the HTML element really so unique that an identifier is required to select it? This usually applies only to the main components of the layout.
So, I would like to replace him with another character. Are there any disadvantages? And is there a general replacement?
You can use any character you want, provided that it is valid in the ID / name of the HTML element, which is specified as follows:
SignsID and NAME must begin with a letter ([A-Za-z]), followed by any number of letters, numbers ([0-9]), hyphens ("-"), underscores ("_"), colons ( ":") and periods (".").
Next to the colon, the only reasonable choices are hyphen, underscore, and period. Since this period itself is a special character in CSS selectors, it will have the same problem as the colon. Therefore, logically you have no choice but a hyphen - and an underscore _ .
As for the flaws, then of course there are flaws. You need to make sure that you are not using the new separator character anywhere in the JSF component identifiers, for example <h:someComponent id="foo_bar" /> in the case of _ . These characters are allowed in the identifiers of JSF components (colon is not specified). This will violate the search for UIComponent#findComponent() .
See also:
source share