Datatable Sort Loses Data

UI Components for JSF
Post Reply
macros14
Posts: 46
Joined: 26 Feb 2010, 19:44

09 Mar 2011, 20:47

Hi,

I just upgraded to the new primefaces 2.2.1. I have a simple datatable with three columns. When I sort on a column, the data in the last two columns disappears. Not sure what I am doing wrong. I always use to do the client side sorting, but that is no longer available, but all of my data items are stings or integers so the AJAX should be working, but doesn't seem to be. I am using a map<String, Integer> which maybe causing the issue??

Code: Select all

<p:dataTable var="cpData" value="#{cc.attrs.dataList}">
            <p:column sortBy="#{cpData.rowName}">
                <f:facet name="header">
                    <h:outputText value="Institution Name" />
                </f:facet>
                #{cpData.rowName}
            </p:column>
            <p:column styleClass="rightAlign" sortBy="#{cpData.columnMap.d1}">
                <f:facet name="header">
                    <h:outputText value="1" />
                </f:facet>
                #{cpData.columnMap.d1}
            </p:column>
            
            <p:column styleClass="rightAlign" sortBy="#{cpData.columnMap.total}">
                <f:facet name="header">
                    <h:outputText value="Total" />
                </f:facet>
                #{cpData.columnMap.total}
            </p:column>
        </p:dataTable>

Code: Select all

@RequestScoped
    public class OriginationReportUI {

        String rowName;
        Map<String, Integer> columnMap;

        public OriginationReportUI() {
            columnMap = new HashMap<String, Integer>();
        }

        public OriginationReportUI(String sRowName) {
            rowName = sRowName;
            columnMap = new HashMap<String, Integer>();
        }

        public Map<String, Integer> getColumnMap() {
            return columnMap;
        }

        public void setColumnMap(Map<String, Integer> columnMap) {
            this.columnMap = columnMap;
        }

        public String getRowName() {
            return rowName;
        }

        public void setRowName(String rowName) {
            this.rowName = rowName;
        }}

macros14
Posts: 46
Joined: 26 Feb 2010, 19:44

09 Mar 2011, 20:49

By the way, the datatable uses a list<OriginationReportUI> And there are items in the list... Though some items in the map may be null which just displays as nothing on the screen but is maybe not handled properly in the ajax sorting?

macros14
Posts: 46
Joined: 26 Feb 2010, 19:44

09 Mar 2011, 23:32

Actually it looks like my list of data might be the issue. Problem is that the list is dynamic based on some dropdowns on the page.

Code: Select all

private int selectedMonth = ReportingUtil.getCurrentMonthAsInteger();
    private int selectedYear = ReportingUtil.getCurrentMonthYearAsInteger();
I guess anything you use to make the list dynamic like the two fields above need to be session scoped?? That doesn't seem to make much sense...

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 69 guests