DataTable: Removed data (rows) remain after update when filtered before

UI Components for JSF
Post Reply
mpint
Posts: 9
Joined: 21 Aug 2018, 11:52
Contact:

18 May 2021, 15:50

Description
When using a List (for example ArrayList) of DTOs for a dataTable and removing some elements from the list, updating the table throw ajax, everythink works fine.
But when I first filter the rows inside the dataTable throw column or global Filter and then remove some of the still visible elements, they remain after ajax update. But the elements are arleady removed from the Java List.

How to reproduce

Visit the PrimeFaces Avalon CRUD example: https://www.primefaces.org/avalon/crud.xhtml and then:
Working example:
  1. Remove the first product throw the trash icon on the right of the row
  2. After the Ajax Update the removed row is gone
Buggy example:
  1. First filter something. For example search for "game". You will see two products
  2. Now remove on of them like in the working example before
  3. After the Ajax Update the removed product still remains
This is a PrimeFaces Bug, not a bug in the Avalon Example Application!

Environment:
- PrimeFaces 10.0.0
- JSF Mojarra 2.3.14.SP01
- Testet in Firefox and Chrome
Freelance software developer and architect
GitHub Profile: https://github.com/MatthiasPischka, visit my blog: https://www.pischka-it.de
PrimeFaces Elite 10.0.1

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

18 May 2021, 22:09

Doesn't look like a bug to me but a bad example. Rows should have unique keys and in this example the Gaming Set or Yoga Mat have the exact same ID. So the datatable can't tell them apart. I would never do this in production my rows always have unique keys.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

mpint
Posts: 9
Joined: 21 Aug 2018, 11:52
Contact:

18 May 2021, 22:20

Yes maybe a bad example but I can reproduce it with unique IDs. Without filtering everythink works fine but after some filtering it is not possible to remove the rows. I have debugged it and saw that the entry in the list are removed but they still remain in the datatable after ajax update. I will provide a simple reproducer application in the next view days.

Same behavior with PrimeFaces 10.0.1.
Freelance software developer and architect
GitHub Profile: https://github.com/MatthiasPischka, visit my blog: https://www.pischka-it.de
PrimeFaces Elite 10.0.1

mpint
Posts: 9
Joined: 21 Aug 2018, 11:52
Contact:

18 May 2021, 22:25

Found a Workaround, but it is still strange: Activate MultiViewState at the dataTable. This works only for the column filters, not for the global filter again.
Freelance software developer and architect
GitHub Profile: https://github.com/MatthiasPischka, visit my blog: https://www.pischka-it.de
PrimeFaces Elite 10.0.1

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

19 May 2021, 22:35

If you can create a reproducer using Primefaces Test please report it on GitHub. See: https://github.com/primefaces/primefaces-test
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

mpint
Posts: 9
Joined: 21 Aug 2018, 11:52
Contact:

20 May 2021, 08:58

Before I create an issue on GitHub let us first look if I do something wrong.

I created a fork of primefaces-test, added a new page (you can get there from the welcome page throw navigation) to reproduce the bug.
Checkout https://github.com/MatthiasPischka/primefaces-test.git
and run as described (mvn jetty:run for example).

Please let me know if I do something wrong. If not I will create an issue on GitHub.
Thanks
Matthias
Freelance software developer and architect
GitHub Profile: https://github.com/MatthiasPischka, visit my blog: https://www.pischka-it.de
PrimeFaces Elite 10.0.1

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

20 May 2021, 13:55

OK two things for your reproducer first to update before you report this issue.

1. Make Product implement Serializable. All values stored in ViewScoped beans must be Serializable.

2. On your table you are missing filteredValue="#{dataTableRemoveBugView.filteredList}" you need to declare a list to hold your filtered values. See the datatable Filter example: https://www.primefaces.org/showcase/ui/ ... ter.xhtml?

3. Change your remove method to remove from both lists...

Code: Select all

  public void remove(Product product) {
    System.out.println("Product to remove: " + product.getLabel());
    this.productList.remove(product);
    this.filteredList.remove(product);
  }
Those changes make your example much more realistic. Now that still leaves the problem of pressing the Remove button on the filtered list not working. That I would report...
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

mpint
Posts: 9
Joined: 21 Aug 2018, 11:52
Contact:

21 May 2021, 20:24

Thanks Melloware. I have updated the example. But it still breaks. The filtered and removed element remains.
I would appreciate if you can look on the updated example again. If you find no other problem I would create an issue on github.
Freelance software developer and architect
GitHub Profile: https://github.com/MatthiasPischka, visit my blog: https://www.pischka-it.de
PrimeFaces Elite 10.0.1

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

21 May 2021, 20:28

No I agree. I was just saying those were missing from your example before you create a github issue. But I agree it looks like an issue.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

mpint
Posts: 9
Joined: 21 Aug 2018, 11:52
Contact:

21 May 2021, 20:44

Thanks again. The issue can be find here: https://github.com/primefaces/primefaces/issues/7336
Freelance software developer and architect
GitHub Profile: https://github.com/MatthiasPischka, visit my blog: https://www.pischka-it.de
PrimeFaces Elite 10.0.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 32 guests