Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8032693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:27:46+00:00 2026-06-05T01:27:46+00:00

I have a PrimeFaces 3.2 DataTable using apache myfaces 2.0.2 . I want a

  • 0

I have a PrimeFaces 3.2 DataTable using apache myfaces 2.0.2 . I want a initial sort. My JSF looks like:

<p:dataTable  id="serverdata" var="serverdata" sortBy="#{serverdata[0]}" sortOrder="descending" 
                value="#{ serverDataTable.list }" rows="10" editable="true" 
                paginator="true" rowsPerPageTemplate="10,20,50"
                paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
                <f:facet name="header">  
                   Datatable
                 </f:facet>
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="Datum"/>
                    </f:facet>
                    <h:outputText value="#{serverdata[0]}">
                    </h:outputText>
                </p:column>

But I get a UnsupportedOperationException: The result list is read-only. When I delete the sortBy tag in it works fine.

So my question:
How can I realize an initial sort?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:27:49+00:00Added an answer on June 5, 2026 at 1:27 am

    The sorting is executed on the original List. If it is read-only, an Exception is thrown. Try the same, but with a regular, mutable List

    EDIT : create a regular list in the bean:

    public class MyBean {
    ...
    List<MyObject> myList = new ArryList<MyObject>();
    myList.add(new MyObject("a"));
    myList.add(new MyObject("b"));
    myList.add(new MyObject("c"));
    ...
    

    then use sorting like this : value="#{myBean.myList}" var="myVar" sortBy="#{myVar.stringProp}"

    EDIT2: If the sorting parameters are strings or numbers, you do not need to customize anything. If you are sorting anything else, you will have to define a custom sortFunction,

    If you use advanced options like lazy loading (which is btw broken in pf 3.2 – you can update to 3.3 now – it has been released on 29.5 and claims to have solved this), you will have to define a custom model, taking care of filtering and sorting yourself.

    So if you want to sort your data by the contents of an array, you would need to define the attribute sortFunction="#{myBean.sortData()}"

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question regarding primefaces datatable component. I want to bind a DataTable
I am working with MyFaces/Primefaces and I have a problem to get information using
I'm using primefaces and jstl to loop a datatable.I have a List in backing
I have a primefaces datatable: <p:dataTable id=idCrawledDataTable var=crawledData value=#{crawlerCorpusTreatmentBean.crawledDataModel} rowKey=#{crawledData.id} rows=10 scrollable=true scrollHeight=300 selection=#{crawlerCorpusTreatmentBean.crawledData}
I have a h:dataTable that displays ProfileNotification like below: <h:dataTable value=#{myBean.profileNotifications} var=item rendered=#{myBean.renderProfileNotification}> <h:column>
I am using Primefaces 3.0. I have a datatable with selectionMode single as shown
I am using JSF 2.0 and PrimeFaces 2.2. I have a data table whose
I have a PrimeFaces checkbox on a JSF page that I'd like to check/uncheck
I'm using JSF 2.0 and primefaces. I have one page with several inputs inside
I am using JSF 2.0 and PrimeFaces 2.2.1. In my template.xhtml, I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.