I have a problem with duplicated ids in my JSF app. I've read in this post that one of the possible solutions is to use Naming Container. Can you give me some example how to use the Naming Container to avoid duplicated ids problem? I use Facelets.
相关问题
- java.lang.NullPointerException at java.io.PrintWri
- h:selectOneMenu in p:dataTable doesn't submit
- PrimeFaces block UI does not work when the compone
- primefaces orderlist not getting updated with the
- JSF2 composite cc.attrs expression does not evalua
相关文章
- How to allow numbers only using f:validateRegex
- JSF 2.0: ajax request when press ENTER
- Formatting a double in JSF
- f:convertNumber on Double: ClassCastException
- SeamPhaseListener - Could not start transaction -
- How do I access EJB bean when inside a custom Conv
- Getting value from dynamically created inputText
- JSF 2.0 javascript onload/oncomplete
I suggest to take a step back and investigate why the duplicate ID problem occurs. Once you nailed the root cause down, then just fix it the "usual" way rather than creating your own
UINamingContainer
component.There are several possible causes for duplicate ID errors which should help you further nailing it down:
UIComponent
s inside the sameUINamingContainer
component.UIComponent
property of the same bean.f:subview
is been declared in the parent page instead of the include page.UINamingContainer
component.new UIComponent()
) without having an ID assigned.Here,
UINamingContainer
is under each the<h:form>
,<h:dataTable>
and<f:subview>
.If the above suggestions doesn't help, then update your question to include the smallest possible code snippet (thus, without all irrelevant code/clutter like unrelated components, libraries, HTML/CSS/JS/etc) which reproduces the exact same problem by just copy'n'paste'n'running it without any changes.
This is what worked for me using JSF1.2 and facelets:
I discovered that neither
<ui:composition>
nor<ui:component>
is actually a naming container, so using the same component more than once in the same form would fail with a duplicate ID exception. This seems like a bad design, as the whole point of components is re-usability. To get around this problem I include a<f:subview>
within each component and set the id on it as a parameter of my component tag:myComponent.xhtml:
and the using it on other pages is simple (after setting up taglib.xml and web.xml correctly):