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 9063991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:08:10+00:00 2026-06-16T16:08:10+00:00

I have a datatable with search field and commandLink to sort. The commandLink that

  • 0

I have a datatable with search field and commandLink to sort. The commandLink that I use to trigger sorting is located not in column header but on the header of datatable. When I load my page and use only commandLink to sort everything works ok. Table sorts in two orders and I see result on my page. Problem appears when I search something in globalFilter. It also works, but after that I cant sort my table. I clear inputText of globalFilter and I cant sort table. To sum up, I see result of sorting only when I not use search field. Sort operation works but request not update the datatable. I put my code below. Maybe somebody knows how to solve it.

<ui:composition>
    <p:panel header="Moje pomiary" footer="#{msgs.footer}" id="myMeasurement">

        <h:form id="form" prependId="false">
<p:dataTable var="m" value="#{myMeasurementTable.measurement}" id="measureList" editable="true"              
             widgetVar="mTable"   
             emptyMessage="No files found with given criteria" filteredValue="#{myMeasurementTable.filteredMeasurement}" >

<f:facet name="header">  
        Sortowanie według: <p:commandLink id="sortByName" actionListener="#{myMeasurementTable.sortByName}" update="measureList">   
    <h:outputText value="nazwa pliku" />  
</p:commandLink>  
        |<h:commandLink action="#{myMeasurementTable.sortByArchivisationDate}"> data archiwizacji </h:commandLink> 
        |<h:commandLink action="#{myMeasurementTable.sortByMeasureDate}"> data badania </h:commandLink> 
        <p:outputPanel styleClass="searchPanel">  
            <h:outputText value="Szukaj: " />  
            <p:inputText styleClass="globalFilter" id="globalFilter" onkeyup="mTable.filter()" style="width:150px" />  
        </p:outputPanel>  
    </f:facet>  

    <p:column headerText="Informacje pomiarowe" style="width:125px" filterStyle="display:none" filterBy="#{m.fileName} #{m.measureDate} #{m.place} #{m.archivisationDate}"
    filterMatchMode="contains" >
    <p:separator styleClass="separatorColumn"/> 
        Nazwa pliku: <h:outputText value="#{m.fileName}" /><br /> 
                Data badania: <h:outputText value="#{m.measureDate}" /><br /> 
                Data archiwzacji: <h:outputText value="#{m.archivisationDate}" /><br /> 
                Miejscowość: <h:outputText value="#{m.place}"/> <br />
                Współrzędne GPS:           
    </p:column>

    <p:column headerText="Wykresy">  
       <img src="/tmp/21/myfile.xls/myfile.xls_Parametr x.png" width="150"/>  
    </p:column> </p:dataTable></h:form></p:panel></ui:composition>

and part of my bean

@ManagedBean(name = "myMeasurementTable")
@ViewScoped
public class myMeasurementTable implements Serializable{


    private static final long serialVersionUID = -9193902657201234669L;
    private List<Measurement> measurement;
    private List<Measurement> filteredMeasurement;
    private boolean sortAscending = true;

    public myMeasurementTable() {
        measurement = new ArrayList<Measurement>();
        fillTable(measurement);
    }

    public String sortByName() {
        System.out.println("naciskam sortowanie");
        if (sortAscending) {
            Collections.sort(measurement, new Comparator<Measurement>() {

                @Override
                public int compare(Measurement m1, Measurement m2) {

                    return m1.getFileName().compareTo(m2.getFileName());

                }
            });
            sortAscending = false;
        } else {
            Collections.sort(measurement, new Comparator<Measurement>() {

                @Override
                public int compare(Measurement m1, Measurement m2) {
                    System.out.println(m2.getFileName());
                    return m2.getFileName().compareTo(m1.getFileName());

                }
            });
            sortAscending = true;
        }
        return null;
    }
  • 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-16T16:08:11+00:00Added an answer on June 16, 2026 at 4:08 pm

    Ok I found solution on primefaces forum. It’s simple. I only added oncomplete=”mTable.filter()” to commandButton and everything works as I want.

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

Sidebar

Related Questions

I don't know that it is possible or not. i have search some links
I have a function that search for a keyword and then return DataTable. I
I'm building a Jquery/JS filtered data table. I have a search input field that
I have a datatable with as search fields. I want a method on the
I have a DataTable X, if I now want to search for a certain
I have datatable with column name tag and 100 rows of data.I need to
I have a Datatable in my C# program that I would like to INSERT
I have a datatable that stores location values as such: CTY_CD, STATE_CD, COUNTRY_CD and
I have a datatable with user information and a column called 'Bits'. There is
Importing a spreadsheet I have filled a DataTable object with that data and returns

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.