primefaces datatable rowedit not updating cell element

前端 未结 5 605
-上瘾入骨i
-上瘾入骨i 2021-01-02 13:21

I have a datatable with rowedit. One column of my table is a cell with a listbox in, the items of the listbox are dynamically retrieved (depending on the value in another c

5条回答
  •  暖寄归人
    2021-01-02 13:49

    OMG it took me a long time to figure this one out. BalusC is as always dead on the money but the thing that escaped me was that updating a Datatable does not update all its children as I expected. Updating the table does in fact update the rows (deleted rows in the underlying model disappear) and reorder rows if the underlying model has been reordered, but values in outputText widgets inside CellEditor containers are not updated, except for the one edited, unless you supply a tag to those you want to update, which in my case was all of them. I am guessing there was a design assumption that when a CellEditor initiated an Ajax call, the Datatable parent would only update the child cell edited. I've never understood why a CellEditor needs both an InputText and an OutputText contained in order to work.

    This led to horrendous problems for me when multiple users concurrently edited the same Datatable in different sessions. UserA would make an edit and get a correctly updated table, potentially with the rows in a different order. Then UserB, whose Datatable was now out of date, would make an edit, and the edit would get persisted to the database correctly (because the row had a unique, hidden ID) but the edit would go to the wrong row in the Datatable (but the correct column), and UserB, even after update, would not see UserA's change in a different cell. Once I put the tag in the inputText body it worked properly. I still had concurrency issues which I had to solve separately, but at least the Datatable was correct after edits.

    BalusC, if you are out there, please correct my bad assumptions here.

提交回复
热议问题