PF10 DefaultSort on DataTable with dynamic columns

UI Components for JSF
Post Reply
fpoulet
Posts: 25
Joined: 22 May 2013, 10:02

09 Jun 2021, 08:53

Hi all,
we face a critical issue since we try to migrate to PF10.
DefaultSort seems working fine on normal DataTable with p:column but not with p:columns (dynamic)

The issue appear in file UITable.java from primeface in the method :
updateSortByWithUserSortBy(FacesContext context, Map<String, SortMeta> intlSortBy, Object usrSortBy, AtomicBoolean sorted)

Code: Select all

  for (SortMeta userSM : sortBy) {
            SortMeta intlSM = intlSortBy.values().stream()
                    .filter(o -> o.getField().equals(userSM.getField()))
                    .findAny()
                    .orElseThrow(() -> new FacesException("No column with field '" + userSM.getField() + "' has been found"));
The content of the Map intlSortBy is always empty which reach in all cases to the FacesException.
with p:column instead p:columns it work fine.

Any idea what we miss or we face a real issue in Primefaces ?

Regards,
Fabrice
PrimeFaces 12.0.2 | PrimeFaces-Extension 12.0.3
Tomcat 9.0
Mojarra 2.3.18 | OpenJdk 17
Cayenne 4.1 |Oracle/SQLServer
Windows 11 | Mozilla FF,Chrome&IE

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

09 Jun 2021, 16:07

When you say "Default sort" can you post how you are setting up the default sort? the XHTML snippet would help.
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

fpoulet
Posts: 25
Joined: 22 May 2013, 10:02

10 Jun 2021, 08:35

Here it is :
Using sortBy from the dataTable

Code: Select all

<p:dataTable id="_tblResults" widgetVar="tblResults" paginator="true" sortMode="multiple" resizableColumns="true"  resizeMode="fit"
            liveResize="true"                     
            value="#{scenarioManager.viewer.pageDataFull}" var="cursor" emptyMessage="#{swafBundle.NoRecord}"
            currentPageReportTemplate="#{swafBundle.currentPageReportTemplate}"
            paginatorTemplate="#{swafBundle.paginatorTemplate}"
            rows="#{scenarioManager.viewer.numberOfRows}"
            first="#{scenarioManager.viewer.selectedPage}"
            sortBy="#{scenarioManager.viewer.storedSortOrder}"
            styleClass="noOverFlow"
            rowsPerPageTemplate="#{userSession.rowPerPageTemplate}" draggableColumns="true" paginatorPosition="bottom" >
            <p:autoUpdate/>
            <p:columns var="column" id="columns" value="#{scenarioManager.viewer.columns}" 
                       columnIndexVar="colIndex" width="#{column.currWidth}" visible="#{column.currVisible}" rendered="#{column.rendered}" 
                       headerText="#{column.header}" sortBy="#{cursor.ui[column.sortBy]}" sortable="#{column.sortable}" exportable="#{column.exportable}" resizable="#{column.resizable}"
                       field="#{column.sortBy}"
                       >

Code: Select all

public List<SortMeta> getStoredSortOrder()
	{
/*		
		initSort();
		if ((m_storedSortOrder==null || m_storedSortOrder.size()==0)) return null;
		return new ArrayList<SortMeta>(m_storedSortOrder.values());
*/
		SortMeta sort = SortMeta.builder()
				.field("ui.name")
				.order(SortOrder.ASCENDING)
				.build();
		List<SortMeta> listSort = new ArrayList<>();
		listSort.add(sort);
		return listSort;

	}
PrimeFaces 12.0.2 | PrimeFaces-Extension 12.0.3
Tomcat 9.0
Mojarra 2.3.18 | OpenJdk 17
Cayenne 4.1 |Oracle/SQLServer
Windows 11 | Mozilla FF,Chrome&IE

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

10 Jun 2021, 14:14

I thnk in your Java your field is wrong for "ui.name" ??
In your dynamic columns you have this field="#{column.sortBy}" and then in your backing Sort By you are claiming the field="ui.name" which is not correct.
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

fpoulet
Posts: 25
Joined: 22 May 2013, 10:02

10 Jun 2021, 14:46

No this is not related to the name, it work fine if i replace p:columns by p:column
And like i explain, the only difference is the content of the of intlSortBy which is empty in case of p:columns, so impossible to find a match with the name in all case.

Regards
PrimeFaces 12.0.2 | PrimeFaces-Extension 12.0.3
Tomcat 9.0
Mojarra 2.3.18 | OpenJdk 17
Cayenne 4.1 |Oracle/SQLServer
Windows 11 | Mozilla FF,Chrome&IE

fpoulet
Posts: 25
Joined: 22 May 2013, 10:02

22 Jul 2021, 11:04

Hi All,
After lot of days investigating, we are still not able to understand this issue.

For the method from UITable.java
updateSortByWithUserSortBy(FacesContext context, Map<String, SortMeta> intlSortBy, Object usrSortBy, AtomicBoolean sorted)
Can someone give us the reason why the Map<String, SortMeta> intlSortBy can be empty ?

When my datatable lazy is display first time, all is fine without data. Multiple sort order are displaying correctly.
I'm able to make a refresh (F5), datatable is refresh correclty keeping sortorder.

After filling the datable with data, all still correct.
After that when i want to make the refresh the crash occurs because the Map become empty.
We are not able to understand why it become suddently empty.

Regards,
Fabrice
PrimeFaces 12.0.2 | PrimeFaces-Extension 12.0.3
Tomcat 9.0
Mojarra 2.3.18 | OpenJdk 17
Cayenne 4.1 |Oracle/SQLServer
Windows 11 | Mozilla FF,Chrome&IE

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 23 guests