I’m trying to use prependId to shorten update commands.
If I use qualified id’s throughout, everything works fine.
If I use prependId, the id cannot be found:
<h:form id="form">
<p:dataTable id="table">
//closing tags
<p:commandButton update=":form:table"> //works
<h:form prependId="false">
<p:dataTable id="table">
//closing tags
<p:commandButton update=":table"> //works NOT!
Cannot find component with identifier “:table” in view.
What am I doing wrong?
This is only correct if
prependId="true". The update attribute requires a clientId to update and by setting prependId to false you are claiming that all elements from within that form will have the same clientId as they have server id. So as Jigar had already mentioned in the comment above, it should just betable.If you don’t believe me then try it for yourself in Firebug and notice the outermost div element for the Primefaces dataTable has an id of just
table. Update will be able to find this regardless of form because it is looking for an id on the page that matches this.This can be dangerous though as it can be very easy to accidentally have multiple components with the same ids in conflict on the DOM. This is even more true for pages that other pages or through including components, third-party or otherwise on a page that have internal DOM elements with unique ID’s as well. These kinds of problems can be extremely difficult to track down.