membersound
membersound

Reputation: 86777

JSF - prependId not working?

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?

Upvotes: 3

Views: 3788

Answers (1)

maple_shaft
maple_shaft

Reputation: 10463

if you want to update from outside the tags you have to use ":". and as I wrote it works with specific id's. I just want to get to know how prependId works instead...

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 be table.

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.

Upvotes: 4

Related Questions