I have a data table. Each row of the table has a commandButton called 'Remove', which is supposed to remove that row from the model and the view and perform an update in-place. As a footer, I have another commandButton called 'Remove every row'.

The last button works. I click on it, every row is removed from the model (i.e the ArrayList containing the elements becomes empty) and the dataTable and footer facet is re-rendered (or updated) in the view.

On the other hand, when I click a button on one of the rows, to remove it, it partially works. The corresponding element is removed from the model but the view is not updated. That row is still there in the dataTable and the footer facet hasn't changed.

Do not ask multiple questions in a single question. One question per question, please :) I have edited the other question out. Also the linked previous question is not related at all. It's maybe the same code, but the problem is absolutely not the same. As to your current problem: which PF version are you using? What if you use update="@form" instead?
–
BalusCJan 10 '12 at 12:51

Sorry for the bad words but thank you very much, once again :) About multiple questions, I'll try to do my best the next time :)
–
Murat Derya ÖzenJan 10 '12 at 13:12

3 Answers
3

I recognize this problem form one of our current PF 3.0 pages. It will work if you use update="@form" instead. I haven't really had the time to investigate the real cause so that I can report it to the PF guys, because this problem does not manifest in all pages. Even in the same table, a different button works as intented.

Give it a try:

<p:commandButton update="@form" ... />

Update: coming to think about it, it's maybe related to the presence of process="@this".

I like your answer better because it is much more efficient and clean. I wonder if this fix will work for apps running on Primefaces 2.2.1 as well? I will have to test this and find out when I have more time.
–
maple_shaftJan 10 '12 at 13:24

I have an existing project in PF 3.2 and this is still an issue. Does anyone know if it has been fixed in a later version?
–
CatfishOct 15 '12 at 19:57

You are probably using Primefaces 2.2.1 as this seems like it is due to a common bug with the Primefaces dataTable component. Essentially what occurs is that ajax postbacks occurring from within elements of a dataTable will not result in a partial page update of elements in the dataTable.

The simplest workaround is to invoke a postback from a button outside of the dataTable where its sole purpose is simply to partial page update the dataTable. This is not the most efficient solution as it results in two postbacks, however it does work.

If you want to use server IDs for updating components (like userTable, somethingElse, ...), these components need to be in the same naming container as the component which triggers the update (your button for example). Otherwise you need to use an expression like this within the update attribute: update=":usersForm:userTable".

The main problem is to identify the naming containers. The outer button does work, because it is in the same naming container (the form) as the table with the ID userTable. The facet gets updated because the whole table gets updated, but since datatable is a naming container itself, it should not be possible to update the footer by just using update="somethingElse" on the outer button.

I'm not sure, why the inner button does not work. I guess there is another naming container within the datatable. PrimeFaces does log an INFO, if the component could not be found using the findComponent algorithm of the UIComponent implementation. INFO: Cannot find component with identifier "userTable" in view.