IllegalArgumentException: sorting function inside column sortBy in JSF

Viewed 87

I have in my code Primeface's datable.

Column documentsConfig.type.key contains DocumentType enum.

I have problem with documentType sorting, it sort records by name of documentType enum (not with documentType enum key message #{msg[documentsConfig.type.key]} ).

Do You know how to sort by values visible in datatables row?

I try to use sortBy="#{msg[documentsConfig.type.key]}", but it gives me

java.lang.IllegalStateException: Illegal attempt to dereference path source [null.type] of basic type

Also i tried sortBy="#{documentConfigurationBean.getPropertyValuePl(documentsConfig.type.key)}"

public String getPropertyValuePl(String key){
    return resourceBundleService.getStringValue(ResourceBundleService.ResourceBundle.MESSAGES,ResourceBundleService.LANG_PL,key);

but it gives me following error, and I dont know how to avoid them

com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [getPropertyValuePl(documentsConfig] on this ManagedType [pl.org.opi.nawa.dao.model.DocumentConfigurationEntity]

<p:dataTable id="documentsConfig"
                 var="documentsConfig"
                 widgetVar="documentsConfig"
                 value="#{documentConfigurationBean.dataModel}"
                 sortMode="multiple"
                 multiViewState="true"
                 editable="false"
                 caseSensitiveSort="false"
                 paginator="true"
                 paginatorPosition="bottom"
                 paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {CurrentPageReport}"
                 currentPageReportTemplate="#{msg['page.owner-manageProgram.field.document.pagination.report']} {totalRecords}"
                 lazy="true"
                 first="#{documentConfigurationBean.dataModel.filter.first}"
                 rows="#{properties.get('grid.rows.count')}"
                 emptyMessage="#{msg['grid.norecordsfound']}"
                 styleClass="-width-100 tabledocconfig">
        <p:ajax event="sort" listener="#{documentConfigurationBean.dataModel.filter.onPageChangeAfterSort}"
                update="#{p:component('documentsConfig')}"/>
        <p:ajax event="page" listener="#{documentConfigurationBean.dataModel.filter.onPageChange}"/>
        <p:ajax event="filter" listener="#{documentConfigurationBean.dataModel.filter.filterListener}"/>
        <p:column headerText="#{msg['configuration.doc.table.header.suffix']}" sortable="true"
                  sortBy="#{documentsConfig.suffix}" width="5%">
            <h:outputText value="#{documentsConfig.suffix}"/>
        </p:column>
        <p:column headerText="#{msg['configuration.doc.table.header.namePL']}" sortable="true"
                  sortBy="#{documentsConfig.namePL}" width="10%" styleClass="-min-width-200">
            <div class="tabsignatura-o-l">
                <h:outputText value="#{documentsConfig.namePL}" styleClass="-break-word"/>
            </div>
        </p:column>
        <p:column headerText="#{msg['configuration.doc.table.header.type']}" sortable="true"
                   sortBy="#{documentsConfig.type}" width="10%">
            <h:outputText value="#{msg[documentsConfig.type.key]}"/>
        </p:column></p:dataTable>
0 Answers
Related