Is there any reason, why the RichFaces built-in client functions (See Chapter 14. Functions), like rich:clientId('id') doesn't find the "closest" element with the given id, instead of searching from the root naming container, returning the first element with the given id? Or is there another way to access the needed "closest" element? It seems that most other things, resolve ids by starting at the closest NamingContainer, moving upwards by parent NamingContainers, searching for the relevant id in each NamingContainer until finally arriving at the root.
If, for example, I have a composition template test.xhtml:
which I use to decorate some example text:
I would expect the output to look like
but instead it renders as
because both functions find the first div on the page with an id of "mydiv", instead of the "closest" (i.e. in the same NamingContainer).
JSF 1.2 didn't provide current component context, that's why the search is done always from UIViewRoot. In RF 4/JSF 2.0 this is changed and the search is done starting from the current component. As a workaround you can qualify id with several more segments, like: container:myDiv.