I wrote a UIComponent which handles my style sheets. This component is
meant to only be placed in one single place in the component tree, and
it is meant to always reside directly under the component tree root. To
make it easy to locate the component, I thought I would enforce it to
always have the same id, so I wrote this code (which does not work like
I expected it to):
public class StylesComponent extends UIComponentBase {
private static final String ID = "styles";
public StylesComponent() {
setId(ID);
}
}
That way I was hoping that people could use my component like this
<styles/>
and automatically get a component with the id "styles". This is not the
case, however, since whenever I do not EXPLICITLY assign an id in the
tag, JSF seems to insist on creating one for me. So even though I wrote
the line "setId(ID);" I still get an automatic id. The hack I am using
at the moment is this:
<styles id="styles"/>
Which has the same effect, but forces my users to remember to assign
this default id which I have chosen.
Can anyone tell me what is wrong or why this is so, and / or how to
achieve such a proper default identifier in an alternative way?
Thanks
Randahl