/ by zero Exception with lazyload+livescroll datatable

UI Components for JSF
Post Reply
ertiop93
Posts: 97
Joined: 29 May 2011, 16:14

18 Nov 2011, 12:36

Getting the following exception while trying to use lazy & livescroll mode together in datatable.

Code: Select all

java.lang.ArithmeticException: / by zero
	at org.primefaces.model.LazyDataModel.setRowIndex(LazyDataModel.java:62)
	at javax.faces.component.UIData.setRowIndexWithoutRowStatePreserved(UIData.java:485)
	at javax.faces.component.UIData.setRowIndex(UIData.java:473)
	at javax.faces.component.UIData.visitRows(UIData.java:2123)
	at javax.faces.component.UIData.visitTree(UIData.java:1437)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
	at javax.faces.component.UIForm.visitTree(UIForm.java:344)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
	at com.sun.faces.application.view.StateManagementStrategyImpl.saveView(StateManagementStrategyImpl.java:149)
	at com.sun.faces.application.StateManagerImpl.saveView(StateManagerImpl.java:133)
	at javax.faces.application.StateManager.getViewState(StateManager.java:553)
	at com.sun.faces.context.PartialViewContextImpl.renderState(PartialViewContextImpl.java:409)
	at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:293)
	at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:183)
	at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:981)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756)
	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:390)
	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:410)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
the xhtml code :

Code: Select all

<p:dataTable value="#{lazyloadBean.lazyList}" var="person" lazy="true" rows="28" liveScroll="true" scrollRows="15" scrollHeight="110" scrollable="true" >
        
the bean :

Code: Select all

@ManagedBean(name="lazyloadBean")
@RequestScoped
public class LazyloadBean {
    
    private LazyDataModel<QuickProfileIntro> lazyList;
    
    public LazyloadBean() {
        lazyList = new LazyDataModel<QuickProfileIntro>() {

            @Override
            public List<QuickProfileIntro> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, String> filters) {
                List<QuickProfileIntro> list = new ArrayList<QuickProfileIntro>(pageSize);
                // filling this list from DB...
                return list;
            }
        };
        lazyList.setRowCount(100000);
        
    }
    
    public LazyDataModel<QuickProfileIntro> getLazyList() {
        Easy.log("getLazyList called");
        return lazyList;
    }   

}
****************************
Using Primefaces 3.4 Snapshot with JSF(Myfaces) 2.1.8

****************************

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

18 Nov 2011, 14:33

Lazy + live scroll not supported.

ertiop93
Posts: 97
Joined: 29 May 2011, 16:14

18 Nov 2011, 15:01

So basically that means that if I implement liveScroll with a huge dataset then the entire dataset would be read all in once but the client would get the results in pieces as he scroll down, right ?

So its just half the purpose solved!? :)

Am I getting it wrong ?
****************************
Using Primefaces 3.4 Snapshot with JSF(Myfaces) 2.1.8

****************************

ertiop93
Posts: 97
Joined: 29 May 2011, 16:14

19 Nov 2011, 22:03

Is this feature going to come anytime in near future ? (in the roadmap ?)
****************************
Using Primefaces 3.4 Snapshot with JSF(Myfaces) 2.1.8

****************************

ulric2
Posts: 11
Joined: 03 Jan 2011, 23:30

23 Nov 2011, 17:07

It also means that filters and sorts can't be applied because client doesn't know the whole dataset.

I really don't understand livescroll concept, as you said it's a half solution.
What is the sense of viewing a huge set of datas you cannot filter or sort ?
What about millions of records loaded on server and memory size?

Everything seems to be in place with lazymodel (serveur sort and filter) and client only display a small part.

Wouldn't it be possible in fixing the number of rows which is not known in scrolling dataTable and link the livescroll event like the change page event ?
PrimeFaces 3.0.M4, Glassfish v3.1.1, Mojarra 2.1.3 (FCS b02), Eclipse Indigo

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

23 Nov 2011, 18:09

I don't see the problem here, Lazy DataModel and LiveScrolling are pretty much incompatible with each other.

You should never be livescrolling through millions of records whereas LazyDataModel with Pagination is probably overkill for a couple of hundred.

Use the right tool for the job.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

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

23 Nov 2011, 19:00

It also means that filters and sorts can't be applied because client doesn't know the whole dataset.
ulric2, I agree. That's why I had to add my own custom filterBy and sorting. See/click URL below and see my response at the very bottom.

viewtopic.php?f=3&t=6824

Well said, andyba!
I don't see the problem here, Lazy DataModel and LiveScrolling are pretty much incompatible with each other.

You should never be livescrolling through millions of records whereas LazyDataModel with Pagination is probably overkill for a couple of hundred.

Use the right tool for the job.
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

ertiop93
Posts: 97
Joined: 29 May 2011, 16:14

27 Nov 2011, 11:50

@Andyba: I agree you shouldn't livescroll on millions of records but why would you even like to retrieve 200 records during livescroll when you just need to show 10 of them initially ? That's increasing the load on the server as well as the database resources.

Isn't that a big disadvantage of current livescroll implementation ?

I don't see the problem here, Lazy DataModel and LiveScrolling are pretty much incompatible with each other.

You should never be livescrolling through millions of records whereas LazyDataModel with Pagination is probably overkill for a couple of hundred.

Use the right tool for the job.
****************************
Using Primefaces 3.4 Snapshot with JSF(Myfaces) 2.1.8

****************************

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

29 Nov 2011, 14:49

ertiop93 wrote:@Andyba: I agree you shouldn't livescroll on millions of records but why would you even like to retrieve 200 records during livescroll when you just need to show 10 of them initially ? That's increasing the load on the server as well as the database resources.

Isn't that a big disadvantage of current livescroll implementation ?

I don't see the problem here, Lazy DataModel and LiveScrolling are pretty much incompatible with each other.

You should never be livescrolling through millions of records whereas LazyDataModel with Pagination is probably overkill for a couple of hundred.

Use the right tool for the job.
I agree with you in part however livescrolling is a feature that does have its uses.

- You don't lose rows of data from sight like you do with paging
- It is a natural way to load chunks of data from the server automatically

It is not good at things like more precise navigation - going to the tail of the data set will result in loading all the data for instance

It doesn't add more load to your Database. Server resources could become an issue however only when you are scrolling through a -lot- of records.

Livescrolling is a suitable alternative to paginated data where the set of data would not preclude the use of one or the other display method and where paging is not required or desired.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

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

02 Dec 2011, 06:47

For others experiencing this error, I just provided a fix/workaround. See/click URL below and see my comment added:

http://code.google.com/p/primefaces/iss ... il?id=1544
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 49 guests