Question: I have a implemented a lazy loading Datatable with primefaces that implements

```
load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String,Object> filters)

```

Now I need to pass parameters from my page to this method (i.e., I have a filter section in my page, the filters are not part of the table, and are independent objects!). My parameters are stored in the page's managed bean.

How can I achieve this?

Thanks!

Answer: 
Make the parameter(s) a property of the bean, and pass them directly to the service that fetches the data from the db (in this example the service is the EJB `MyObjFacade myObjFacade`):

```
@ManagedBean
@ViewScoped
public class MyBean {
    @EJB
    private MyObjFacade myObjFacade;
    private LazyDataModel<MyObjType> model;        // getter
    private MyParameter myParameter;

    @PostConstruct
    public void init() {
        model = new LazyDataModel<MyObjType> () {

            @Override
            public List<MyObjType> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, String> filters) {
                model.setRowCount(myObjFacade.count(filters, myParameter));
                return myObjFacade.getResultList(first, pageSize, sortField, sortOrder, filters, myParameter);
            }
        };
        model.setRowCount(myObjFacade.count(new HashMap<String, String> ()));
    }
}

```

You simply have to provide the service implementing `count` and `getResultList` methods.
After many hours searching I finally did it. I leave here my solution for further reference.

```
//Managed Bean - View
public class DummyLazySearchPageBean {

    private LazyDataModel<DummyObject> results;
    private String searchFilter;//to simulate search filter
    private DummyBusinessClass dummyBusinessClass;

    public DummyLazySearchPageBean() {
        results = new SearchsLazyLoader();
    }

    // GETTERS AND SETTERS

    @SuppressWarnings("serial")
    private final class SearchsLazyLoader extends LazyDataModel<DummyObject> {
        @Override  
        public List<DummyObject> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String,Object> filters) {
//Simulate BD model         
List<DummyObject> data = new ArrayList<DummyObject>();
            dummyBusinessClass = new DummyBusinessClass();

            data = dummyBusinessClass.search(searchFilter, 5000);

            //rowCount
            this.setRowCount(data.size());

              //paginate
              if(data.size() > pageSize) {
                  try {
                      return data.subList(first, first + pageSize);
                  }
                  catch(IndexOutOfBoundsException e) {
                      return data.subList(first, first + (data.size() % pageSize));
                  }
              }
              else {
                  return data;
              }
        }
    }

    public final void search(){
        results = new SearchsLazyLoader();
    }
}

```