I have a project where OmniFaces 2.6.8 is used. In this project I have some facelets tag files, which use OmniFaces' <o:tagAttribute>
. For some of my tagfiles I noticed strange behavior, which means, the <o:tagAttribute>
seems not to be working and I get
IllegalStateException: Duplicate component ID 'myForm:outer' found in view.
as a result, because the id
-attribute of my outer tag is not cleared and thus reused in the inner tag (just as demonstrated in OmniFaces' show-case).
I could reproduce the problem with two very simple tag-files. Here is how I use those tag-files first:
<h:form id="myForm">
<my:outer id="outer">
<my:inner />
</my:outer>
</h:form>
And here is the complete code of the tag-files.
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:o="http://omnifaces.org/ui">
<o:tagAttribute name="id" />
<h:panelGroup id="#{id}">
<ui:insert/>
</h:panelGroup>
</ui:composition>
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:o="http://omnifaces.org/ui">
<o:tagAttribute name="id" />
<h:inputText id="#{id}">
<ui:insert/>
</h:inputText>
</ui:composition>
I noticed, that the problem does not arise, as soon as I change inner.xhtml
to use <h:outputText>
instead of <h:inputText>
. It also disappears, when I add a value
-attribute to the <h:inputText>
.
Is this a bug in OmniFaces, or am I doing something wrong?
(Update: I created an issue in the OmniFaces bugtracker.)
This was a bug in OmniFaces 2.6.8, which was fixed (but not mentioned in the changelog) in OmniFaces 2.6.9. Exchanging the dependency version of OmniFaces is enough to solve the described problem.
Update: Note, that there is also a related issue, which was fixed in 2.7.1.