webtier@glassfish.java.net

Re: composite component with "for" attribute in jsf2.0 - is it possible?

From: <webtier_at_javadesktop.org>
Date: Thu, 01 Apr 2010 09:49:55 PDT

Apparently, you've nested your component inside other parent components.

I don't know [i]the best[/i] solution, but I can give you some clues:

It might be best for you to put explicit ID's to all the parent components, and not to rely on JSF to generate the ID's. Thus, at least you can be sure that the ID's will be same every time. For example, the form could have an explicit ID:

[code]
<h:form id="myForm">
    ...
</h:form>
[/code]

Then, if there are no additional nestings, the component ID should be something like "myForm:userNameInput" instead of "j_idt10:userNameInput". For each element in the path, you should provide an explicit ID.

Then, in the [b]for[/b] attribute of your custom element provide the full ID:

[code]
<my:comp for="myForm:myParentElem:userNameInput"/>
[/code]

I know this is ugly but I don't know any other way.

Mind you, I'm not saying there's no other way. Perhaps there is. I just don't know it.

Maybe one of the gurus might drop a comment here...
[Message sent by forum member 'vesuvius']

http://forums.java.net/jive/thread.jspa?messageID=394919