On Fri, 2006-01-06 at 20:04 +0100, Volker Weber wrote:
> Hi Travis,
> I think i should read this tread.
>
> [1] http://www.mail-archive.com/[email protected]/msg00680.html
I think that thread is missing a lot of information.
The spec requires that a subform is a naming container, and prefixes the
ids of all child components with its own id, so that this can be done:
<h:form id="foo">
<h:inputText id="in" ../>
<f:subview id="view1">
<jsp:include page="footer.jsp"/>
</f:subview>
</h:form>
where the footer also includes some component with id="in". This is a
very important feature, and I can't see how it could be done any other
way than by the "naming container" approach. If people modifying
"included" pages had to look for every place where the page was included
and make sure they did not use any ids that were already in use by
including pages that would be a maintenance nightmare.
In addition, the portlet viewhandler prefixes the ids of all components
with a unique portlet-id, so that there is no chance of id conflicts
between independently-developed portlets. Again, I see no sane alternate
solution; the portlets are *independent* yet the final page must not
have any duplicated ids (and neither may may the JSF View tree).
The h:dataTable component is a NamingContainer for its children for very
good reasons too. Again, any component within a table that has a
user-provided id *must* have its HTML id tweaked in some way, as
multiple HTML components will be output and IDs must be unique.
Whether the h:form needed to be a naming container is debatable; I can't
for the moment see a reason for that. The ADF
form-that-is-not-a-naming-container component sounds like a good idea to
me; it's not a 100% solution but seems a straightforward solution to 95%
of cases. Anyone care to point out a good reason for having Form be a
naming container?
None of this was discussed in the thread referenced above. And
unfortunately the current "forceid" solution suffers from the first two,
and has an inelegant solution to the third.
As Craig mentioned, any JS code created by a renderer should simply pass
its id, or a reference to itself, to javascript methods it invokes.
However that doesn't apply in all cases.
Javascript invoked as a component's event handler can simply reference
"this" to get the source component which avoids the need for ids at all
in this situation.
See also:
http://wiki.apache.org/myfaces/forceId
Regards,
Simon