problem with data table lazy loading primefaces-2.2. m1

UI Components for JSF
maya
Posts: 25
Joined: 23 Aug 2010, 13:44

07 Sep 2010, 14:20

hi

I m using primefacs (PrimeFaces-2.2.M1) and jsf 2.0 ..i m trying to implemented lazy loading .. at the inital time the data table is displaying properly , after clicking the NextPageLink the datatable is displaing the same content ,and getting exception like this

java.lang.ArithmeticException: / by zero
at org.primefaces.model.LazyDataModel.setRowIndex(LazyDataModel.java:62)
at javax.faces.component.UIData.setRowIndex(UIData.java:448)
at javax.faces.component.UIData.visitTree(UIData.java:1184)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1457)
at javax.faces.component.UIForm.visitTree(UIForm.java:333)

how can i solve this problem ?

at the inital time the load method is calling but from second time onwards (when i click the nextpagelink) the load method is not calling ..
Last edited by maya on 08 Sep 2010, 11:34, edited 5 times in total.

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

07 Sep 2010, 15:43

Does showcase work for you?

User avatar
MISS_DUKE
Posts: 273
Joined: 08 Aug 2010, 05:52

07 Sep 2010, 16:58

I also experience the same error:

Code: Select all

SEVERE: java.lang.ArithmeticException: / by zero
In my case the pagination buttons are disabled but the first page is displayed properly without error messages. I tried with various values for "row" attribute in the markup, the first page displays the correct number of rows.

When I try to change the rows per page from the drop down (in the display), it is not working and the above error thrown.

"(0 of 0)" is always shown at the footer bar of the table when 1st page is displayed.

Component showcase is working properly.

(My M1SNAPSHOT is as of 3 Sep)
JSF implementation: Mojarra V2.1.7
JSF component library: Primefaces V3.1.1
Server: GlassFish Open Source Edition V3.1.1 (build 12)

maya
Posts: 25
Joined: 23 Aug 2010, 13:44

07 Sep 2010, 17:30

yes primefaces show case working properly..

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

07 Sep 2010, 18:01

Snapshots are not supported and we can't replicate it on our end, we can start discussing this once this feature gets a release number so we can do proper tracking of issues, dates can't help for sure to keep track of things.

User avatar
MISS_DUKE
Posts: 273
Joined: 08 Aug 2010, 05:52

08 Sep 2010, 04:24

I have the same problem with Primefaces 2.2 M1 as well.
Last edited by MISS_DUKE on 08 Sep 2010, 10:07, edited 1 time in total.
JSF implementation: Mojarra V2.1.7
JSF component library: Primefaces V3.1.1
Server: GlassFish Open Source Edition V3.1.1 (build 12)

maya
Posts: 25
Joined: 23 Aug 2010, 13:44

08 Sep 2010, 11:27

in lazy data model class ..at inital time when i load lazy loading data table the pageSize come as what value i specied in row attribute in the datatable but when the secontd time pageSize coming as 0 and rowIndex -1. how can i resolve this ?

this setter method only throwing the following exception ..... java.lang.ArithmeticException: / by zero..........

public void setRowIndex(int rowIndex) {
this.rowIndex = (rowIndex % pageSize);
}

thanks
Maya

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

08 Sep 2010, 14:03

Make sure your lazydatamodel has a scope wider than request. Or compare with showcase example until the user's guide is ready. Or you can help us by providing a case code which we can try to replicate.

User avatar
MISS_DUKE
Posts: 273
Joined: 08 Aug 2010, 05:52

08 Sep 2010, 14:47

When I changed my lazyDataModel to viewScope or SessionScope no errors thrown and rows per page drop down works properly.

But pagination buttons are still disabled, always shown (0 of 0) at the bottom.
JSF implementation: Mojarra V2.1.7
JSF component library: Primefaces V3.1.1
Server: GlassFish Open Source Edition V3.1.1 (build 12)

User avatar
MISS_DUKE
Posts: 273
Joined: 08 Aug 2010, 05:52

08 Sep 2010, 15:20

My LazyModel implementation as follows

Code: Select all

import java.util.List;
import java.util.Map;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.primefaces.model.LazyDataModel;

@ManagedBean
@ViewScoped
public class Master2Backing extends LazyDataModel<Object> {

    @EJB
    SearchSession2 searchSession;
 
      public Master2Backing() {
    }

    public LazyDataModel getLazyDataModel() {
        this.setRowCount(searchSession.getSearchResultCount());
        return this;
    }

    @Override
    public List<Object> load(int first, int pageSize, String sortField, boolean sortOrder, Map<String, String> filters) {
        return searchSession.getSearchResult(first, pageSize);
    }
}

Code: Select all

import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Stateless
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class SearchSession2 {

    @PersistenceContext(unitName = "myContext")
    EntityManager em;

    public List getSearchResult(int firstResult, int pageSize) {
        List list = em.createNamedQuery("Me.search").setFirstResult(firstResult).setMaxResults(pageSize).getResultList();
        return list;
    }

    public Integer getSearchResultCount() {
        Object count = em.createNamedQuery("Me.count").getSingleResult();
        return Integer.valueOf(((Long) count).intValue());

    }
}
JSF implementation: Mojarra V2.1.7
JSF component library: Primefaces V3.1.1
Server: GlassFish Open Source Edition V3.1.1 (build 12)

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 44 guests