Filtering is not working for dataTable Lazy Loading

UI Components for JSF
Sunil
Posts: 47
Joined: 23 Jun 2011, 09:15

06 Aug 2011, 09:51

Hi All,

Can any one help me in performing filterBy in dataTable Lazy Loading.

Problem:None is displayed while entering a word in filterBy in column of dataTable.
Please help at earliest :(

bean file:

Code: Select all


 public LazyDataModel<Breeder> getBreederLazy() {
        return breederLazy;
    }

    @PostConstruct
    public void createDataModel() {
        LazyDataModel m = new LazyDataModel<Breeder>() {
            public List<Breeder> load(int start, int size, String order, boolean desc, Map<String, String> filter) {
                List<Breeder> result = ejbFacade.load(start, size, order, desc, filter);
                return result;
            }
        };
        breederLazy = m;
        breederLazy.setRowCount(ejbFacade.findAll().size());

    }

XHTML file :

Code: Select all

<p:dataTable id="table1"
                                 value="#{breederController.breederLazy}"
                                 var="item"
                                 lazy="true"
                                 widgetVar="table1"
                                 selectionMode="single"
                                 selection="#{breederController.breederID}"
                                 update="display"
                                 onselectComplete="edited.show()"
                                 paginator="true" rows="5" 
                                 paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"  
                                 rowsPerPageTemplate="5,10,15" 
                                 paginatorPosition="both"
                                 styleClass="Table"
                                 dynamic="true">

<p:column sortBy="#{item.breederName}"  filterBy="#{item.breederName}" filterStyleClass="searchOption" >
                            <f:facet name="header">
                                <h:outputText value="#{bundle.BreederTitle_breederName}"/>
                               
                            </f:facet>
                            <h:outputText value="#{item.breederName}" style="color:rgb(#{item.idCooperative.color})"/>
                        </p:column>
                                 

http://imageshack.us/photo/my-images/694/filterd.png/


Thanks in Advance,
Sunil :|

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

06 Aug 2011, 10:19

Do you include filters when you query the db. You need to do the filtering yourself in lazy mode.

Sunil
Posts: 47
Joined: 23 Jun 2011, 09:15

06 Aug 2011, 10:34

yes! But how to do filtering in lazy mode :?:

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

06 Aug 2011, 11:45

Query db with sql, jpa whatever you use for persistance.

Sunil
Posts: 47
Joined: 23 Jun 2011, 09:15

06 Aug 2011, 12:23

Can u show me the example?

robert.m
Posts: 226
Joined: 07 Dec 2010, 22:52
Location: Salzburg/Austria

08 Aug 2011, 14:42

Have a look at this example: http://javaeeinsights.wordpress.com/201 ... teria-api/

The "lazyLoad"-method in the example will be the "ejbFacade.load"-method in your code.

Sunil
Posts: 47
Joined: 23 Jun 2011, 09:15

09 Aug 2011, 07:26

Even though i did like the above example, i couldn't get exact solution.
Am using EclipseLink(JPA 2.0) for my project.
Can you help me in getting the exact solution for this.
Awaiting your reply :(

robert.m
Posts: 226
Joined: 07 Dec 2010, 22:52
Location: Salzburg/Austria

09 Aug 2011, 10:41

Please post the code of your ejbFacade.load method

sebasrock
Posts: 5
Joined: 03 Nov 2011, 16:31

16 Nov 2011, 17:10

but , the problem is that value of FilterBy is equal to name variable, but dont have the value of variable

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

17 Nov 2011, 02:01

Look for my response to the post/question at the URL below. This is my workaround for p:dataTable filterBy issue(s). :)

viewtopic.php?f=3&t=6824
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 63 guests