问题
I have a jsf 2.0 page with a <p:dataTable> and inside this table a <p:commandButton> that should delete an item from this table with an ajax request. The deleting itself works fine, but I do not know how to identify the surrounding <p:dataTable> for the render update.
<lots of naming containers>
...
<p:dataTable id="dataTable" var="userItem" ... />
<p:column>
<p:commandButton
action="#{userController.doDelete(userItem.id)}"
value="delete"
update="?????"/> <!-- How to address the dateTable? -->
</p:column>
</p:dataTable>
<.lots of naming containers>
I already tryed
(Edit: it did not worked for an other reason)update="dataTable" but mojarra did not find it
So my question is how to address the surrounding naming container, WITHOUT using a absolute path that starts at root UIComponent (because then I would need to name a lot of naming containers.)
回答1:
Assuming that you have everything within a form that has prependId="false" as an attribute, then the update attribute value of dataTable should work.
The PrimeFaces update attribute of child components recognizes the id of a parent dataTable component. Furthermore you can also use the @parent value within PrimeFaces update to re render a child elements immediate parent container.
来源:https://stackoverflow.com/questions/12088654/how-to-address-the-surrounding-naming-container-in-jsf