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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:36:45+00:00 2026-06-06T14:36:45+00:00

I have an implementation of lazyDataModel following this tutorial http://uaihebert.com/?p=1120 My code its a

  • 0

I have an implementation of lazyDataModel following this tutorial http://uaihebert.com/?p=1120

My code its a bit different from this tutorial, here it is:

View:

<p:dataTable id="tablaClientes"  value="#{AgendaManualMBean.allClientes}" 
   var="tablaClientes" 
   widgetVar="clienteTable" 
   rowKey="#{tablaClientes.clDocid}" 
   selection="#{AgendaManualMBean.ciatt001}" selectionMode="single"  rows="10" 
   lazy="true" paginatorPosition="top" 
   paginatorTemplate="{RowsPerPageDropdown}{FirstPageLink}{PreviousPageLink} 
   {CurrentPageReport} {NextPageLink} {LastPageLink}" rowsPerPageTemplate="5,10,15"
   emptyMessage="No existen clientes">

                <f:facet name="header" >  
                    <p:outputPanel>  
                        <h:outputText value="Busqueda " />  
                        <p:inputText id="globalFilter" onkeyup="clienteTable.filter()" 
                         style="width:150px"  size="10"/>  
                    </p:outputPanel>  
                </f:facet>  

                <p:column id="numOrdenColumn" filterBy="#{tablaClientes.clDocid}"  
                          width="50"              
                          headerText="Identificación" 
                         
                          filterMatchMode="contains">  
                    <h:outputText value="#{tablaClientes.clDocid}" />  
                </p:column>  
                <p:column id="nomCliColumn" 
                          filterBy="#{tablaClientes.clNombre1}"   
                          width="250"
                      
                          headerText="Cliente" 
                          filterMatchMode="contains">  
                    <h:outputText value="#{tablaClientes.clNombre1}" />  
                </p:column>  

            </p:dataTable> 

MY Managed Bean:

 public LazyDataModel<Ciatt001> getAllClientes() {
    if (listaClientesLazy == null) {
        listaClientesLazy = new LazyClienteModel(ambiente.getCodCia(),ambiente.getCodAge());
        //listaClientesLazy = new LazyClienteModelMBean();
    }

    return listaClientesLazy;
}

My LazyDataModel

public List<Ciatt001> load(int startingAt, int maxPerPage, String sortField, SortOrder sortOrder, Map<String, String> filters) {
    String a = "";
    try {   
    listaClientes = new ArrayList<Ciatt001>();
    a = String.valueOf(agendamientoSession.countClientes2(cia, age));
    listaClientes = agendamientoSession.listaClientes2(cia, age, startingAt, maxPerPage);
    } catch (Exception e) {
        e.printStackTrace();
    }
    
    if (getRowCount() <= 0) {
      setRowCount(Integer.parseInt(a));
     }
    setPageSize(maxPerPage);
     return listaClientes;  
    }

@Override
public Object getRowKey(Ciatt001 ciatt001) {
    return ciatt001.getClDocid();
}

@Override
public Ciatt001 getRowData(String docid) {
    //Integer id = Integer.valueOf(idBandeja);

    for (Ciatt001 ciatt001 : listaClientes) {
        if (docid.equals(ciatt001.getClDocid())) {
            return ciatt001;
        }
    }

    return null;
}       

And the ejb methods:

 public List<Ciatt001> listaClientes2(String cia, String age  ,int startingAt, int maxPerPage) {

    Query query = em.createNamedQuery("Ciatt001.listaClientesPorCiaPorAge2");
    query.setParameter(1, cia);
    query.setParameter(2, age);
    query.setFirstResult(startingAt);
    query.setMaxResults(maxPerPage);
    return query.getResultList();
}
    public String countClientes2(String cia, String age) {

    Query query = em.createNamedQuery("Ciatt001.countClientes2");
    query.setParameter(1, cia);
    query.setParameter(2, age);     
    return query.getSingleResult().toString();
}

How can I achieve a global filter using this lazy loading implementation?

  • 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-06T14:36:45+00:00Added an answer on June 6, 2026 at 2:36 pm

    On load functon, get the filter value (check if is not null).

    String filterValue = filters.get("globalFilter");
    

    Then if you are not using any others filters ,make a query using disjunction (OR):

    "select * from table where x = ? OR y = ?" //replace ? for globalFilter value
    

    If you are using others fields, you should do:

    //normal filters 
    filtersCondition  = "(x = ? AND y = ?)" //replace ? for filters values
    //global filters
    globalFilterCondition = "(x = globalFilter OR y = globalFilter)" //replace ? for globalFilter value
    //normal filters + global filter
    query = "select * from table where " +filtersCondition+ " AND "+ globalFilterCondition
    

    Of course, this queries are just an example , you should build a nice one and well parameterized =)

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

Sidebar

Related Questions

I downloaded the JSON2.js from https://github.com/douglascrockford/JSON-js/blob/master/json2.js and it does not have implementation for JSON2.stringify()
Does anyone have base32 implementation in Delphi? I found: http://cc.embarcadero.com/item/21566 but it is not
I have this implementation with fusion table layers where I try to use the
I don't know either my implementation have bugs or StringBuilder is going wrong. From
What strategy should I use if I have an implementation of std::fstream with 32-bit
In my implementation I have this: /// <inheritdoc cref=IInterface{T} this[,]/> public T this[long row,
I have this implementation of the sieve of Eratosthenes in Clojure: (defn sieve [n]
I currently have a implementation where some markers coming from JSON list is shown,
I have this implementation in C#. If I am not wrong, it is used
I have IValueConverter implementation - IconExtractor . I use it this way: <Image Source={Binding

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.