question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DataTable/TreeTable: sortBy not working with client saving state method

See original GitHub issue

Describe the defect After migrate from PF8 to 10, all DataTables and TreeTables with “sortBy” defined in columns stops to work.

Trying to debug I could see that in org.primefaces.component.datatable.feature.SortFeature.class , from line 152: Map<String, SortMeta> sortBy = table.getActiveSortMeta(); is always empty and Object varBackup = context.getExternalContext().getRequestMap().get(var); is null.

I also note that getSortByAsMap().values().stream().filter(SortMeta::isActive) shows that ‘SortMeta cannot be resolved’. I can confirm that all of them was working fine in PF previous version. Anyone could help?

Environment: PF Version: 10.0.0-RC1 JSF + version: JSF 2.2.19 Affected browsers: Chrome, Safari Locale var: ‘pt_BR’

Reproducer: https://github.com/edudoda/primefaces-test-cases

To Reproduce 0. Set STATE_SAVING_METHOD as client in web.xml:

  <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>     <!--  when = 'server' is ok!  -->
    </context-param>

  1. Go to ‘<p:dataTable’ component with any column defined with a single like ‘<p:column sortBy=“#{item.name}”’
  2. Click on ‘Sort header.’
  3. Nothing changes.

Expected behavior

Example XHTML

 <p:column    sortBy="#{item.name}"      >    

Example Bean

public void sort(FacesContext context, DataTable table) {
        Object value = table.getValue();
        if (value == null) {
            return;
        }

        List<?> list = resolveList(value);    //ok with objects
        Locale locale = table.resolveDataLocale();   // << pt_BR
        String var = table.getVar(); // << item
        Collator collator = Collator.getInstance(locale);   //<< java.text.RuleBasedCollator@289747d6
        AtomicInteger comparisonResult = new AtomicInteger();  // <<  = 0
        Map<String, SortMeta> sortBy = table.getActiveSortMeta();  //   = {}  SortMeta cannot be resolved'

        Object varBackup = context.getExternalContext().getRequestMap().get(var); // = null

        list.sort((o1, o2) -> {
            for (SortMeta sortMeta : sortBy.values()) {
...

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:30 (16 by maintainers)

github_iconTop GitHub Comments

4reactions
tandraschkocommented, May 4, 2021

fixed it now by removing UIComponent from Meta they were transient and not correctly initialized, also UIComponent shouldnt be used actually, therefore we have invokeOnColumn

3reactions
tandraschkocommented, May 4, 2021

@mertsincan @sqores good candidate for 10.0.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

PrimeFaces 10: sortBy not working in p:dataTable
Documentation states that sortBy expects a single or a collection of ... DataTable/TreeTable: sortBy not working with client saving state ...
Read more >
State Saving does not work — DataTables forums
When this "fnStateSave" function is called? Is that happens each and every state change in data table such as sorting, pagination etc.?
Read more >
DataTable Sorting - Documentation - Webix
DataTable allows you to sort data rows on the client side. There are 2 ways to invoke sorting in the table: By a...
Read more >
Primefaces Tree, TreeNode, TreeTable Example Tutorial
Some of those technical issues are covered randomly along spread ... the tree nodes in model are rendered to the client and tree...
Read more >
Lightning dataTable sortedDirection not working
Handle the onsort event handler to update the table with the new column index and sort direction. There is no change for sorting...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found