webtier@glassfish.java.net

Re: [webtier] Re: JSF 2.0 : Inconsisted use of composite attributes in component fields

From: Ed Burns <Ed.Burns_at_Sun.COM>
Date: Thu, 25 Feb 2010 05:31:18 -0500

On 2/25/10 2:40 AM, webtier_at_javadesktop.org wrote:
> Okay, having done some more reading, it seems that JSF takes it upon itself to generate id
> values (and name values) for components in a composite, which is why I can't set the id on
> the inputText without it being modified.

Yes, this is because composite components are, by necessity, naming
containers.

> But does that mean it's impossible to match a "for" attribute in a label or a message with
> an "id" attribute of an input field? (without some ugly hack like doubling up the supplied
> id in the "for" fields to make them match the value generated in the "id" field. I am sure
> something like that cannot be relied upon in future releases)

Certainly your requirement is already satisfied. You have to do
something like this:

<h:outputLabel for="#{cc.clientId}:password" ...

This gets the proper client id for the top level component (either auto
generated, or manually assigned by the page author in the using page).

Ed