9

I'm loving the jsf 2.0 composite component setup. One other thing I love is prependId="false" on forms. Is there an equivalent that can be defined in cc:interface or cc:implementation that will prevent jsf from creating a j_id to prepend to the ids defined within the composite component?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Dave Maple
  • 8,102
  • 4
  • 45
  • 64

1 Answers1

11

That's not possible. Just give the component a fixed id instead letting JSF autogenerate one. The same applies on forms by the way. This way you can still select them using CSS selectors.

Or better, just give them a styleClass so that you don't need to select by ID, for the case that this aversion was actually caused by inability to select components/elements by client ID (I don't see other feasible reasons).

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 1
    that will work. I get all the html from the creative department and it would be nice to be able to use their ids as delivered but I bet they'll change them up for future projects if I let them know the format. – Dave Maple Mar 09 '11 at 01:09
  • Note that the default JSF separator `:` is illegal in CSS. You'd have to escape them as `\3A ` (with space behind). In JSF 2.0 you can however configure it as `javax.faces.SEPARATOR_CHAR` context param in `web.xml`. Use for example `-` (and ensure that you don't use it elsewhere in fixed ids). – BalusC Mar 09 '11 at 01:16
  • very cool. we have style sheets full of \3A so it would be nice to replace those. – Dave Maple Mar 09 '11 at 15:36
  • Very true, but just as a reference: when using jQuery one can select the default colons by escaping them, like `$("#some\\:id").focus();` for ``. – Arjan Feb 03 '12 at 09:31
  • 2
    @Arjan: or `$("[id='some:id']")`. See also http://stackoverflow.com/questions/7927716/how-to-select-primefaces-ui-or-jsf-components-using-jquery/7928290#7928290 – BalusC Feb 03 '12 at 12:53