Another very important NamingContainer is f:subview (aka UINamingContainer).

As Mike says, the tomahawk extension "forceId" causes the specified id value to be used literally, without any NamingContainer prefixes. However it's a dangerous option; it makes composing pages from multiple parts risky as two components might have the same id.

From the fact that you've got a naming container with id "content" in the hierarchy, it looks like you're using Tiles to compose pages. This is a prime example of where conflicting ids can occur when forceId is used: the authors of all the parts used to compose a page must ensure they don't use the same ids in different parts. For me, forceId is like hacking Java so that class member variable names can conflict. Yecch.

I'm not saying that you should avoid forceId; it may be the "least worst" option in some cases. However I think a better solution is really needed.

Are you aware that in event-handler code called from a DOM component (eg an "onclick", the called javascript method can use "this" to refer to the component that the event fired on? This can remove the need to know the component's id at all in some cases.



Mike Kienenberger wrote:
The naming is based on NamingContainers.

     * If this component is a descendant of a NamingContainer then the
     * client id is of form "{namingContainerId}:{componentId}".

I can't remember all of which components implement NamingContainer,
but I think it's UIForm and UIData.   UIData uses
"{namingContainerId}:{componentId_#}", I believe.

I think there's also a tomahawk extension attribute called "forceId",
which, when set to true, will bypass naming containers and use the raw
id value specified, but I haven't used it.


On 12/12/05, Steve Ivy <[EMAIL PROTECTED]> wrote:

I'm working on the front end for a JSF app, and I'm trying to add some
interactivitiy to the interface via javascript. Typically you do a lot

document.getElementById ('someId').etc ()

But I find that setting the id in JSF usually results in something
like id="content:_id35:nameHelp". I'm not sure how these ids are
assigned, and I'm not sure how I can predict what id an element will
have in order to acess it via javascript (or css for that matter, but
that's another rant). Are there accepted methods of getting around



Steve Ivy

Reply via email to