DataTable/TreeTable: sortBy not working with client saving state method
See original GitHub issueDescribe 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>
- Go to ‘<p:dataTable’ component with any column defined with a single like ‘<p:column sortBy=“#{item.name}”’
- Click on ‘Sort header.’
- 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:
- Created 3 years ago
- Reactions:3
- Comments:30 (16 by maintainers)
Top GitHub Comments
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
@mertsincan @sqores good candidate for 10.0.1