PrimeFaces dataTable sorting not working

后端 未结 3 500
孤独总比滥情好
孤独总比滥情好 2020-12-21 15:40

I am having trouble getting the PrimeFaces dataTable component\'s sort behavior to work as documented. (I am using PrimFaces 4.0, JSF 2.1.12, and Tomcat 7.0.) The problem I

相关标签:
3条回答
  • 2020-12-21 16:19

    My datatable was not sorting due to the existence of lazy="true". When I removed that, it worked. I realize you are not using that attribute, however.

    0 讨论(0)
  • 2020-12-21 16:27

    Your firs string is

    <p:dataTable id="dataTable" var="car" value="#{tableBean.cars}">
    

    so tableBean has a method

    public List<Car> getCars()
    {
        return carEJB.findAll();
    }
    

    but your bean has no variable to save method result after sort.

    Solution:

    public class CarController
    {
    ...
        private List<Car> cars;
    ...
        privare void reset()
        {
            cars = carEJB.findAll();
        }
    ...
        public List<Car> getCars()
        {
            return cars;
        }
    }
    
    0 讨论(0)
  • 2020-12-21 16:39

    remove the pound and curly bracket like this:

    From this:

    <p:column sortBy="#{car.manufacturer}">
    

    To this

    <p:column sortBy="manufacturer">
    

    I had the same problem and it was simply because of that.

    0 讨论(0)
提交回复
热议问题