I am trying to use tapestry5 jquery component PageScroll for infinite
scrolling.
- tapestry5 - 5.3.8
- tapestry5-jquery - 3.4.2
So far i got this:
public class PageScrollDemo {
private static final int PageSize = 100;
@Property
private int value;
@OnEvent("nextPage")
List<Integer> moreValues(int pageNumber) throws InterruptedException {
List<Integer> values = new ArrayList<Integer>();
int first = pageNumber * PageSize;
for(int i = 0; i < PageSize; ++i){
values.add(first + i);
}
Thread.sleep(1000);
return values;
}}
PageScrollDemo.tml
<html
xmlns:t='http://tapestry.apache.org/schema/tapestry_5_3.xsd'><body><h1>BEGIN</h1><ul>
<li t:type='jquery/pagescroll' row='value' scroller='scroller'
zone='zone' pageNumber="1">
<li>${value}</li>
</li>
<li class='zone' t:type='zone' t:id='zone'/></ul><div
id='scroller'></div><h1>END</h1></body></html>
But i get this error
java.lang.RuntimeExceptionCoercion of [] to type java.lang.Integer
(via String --> Long, Long --> Integer) failed: For input string: "[]"
java.lang.NumberFormatExceptionFor input string: "[]"
Filter stack frames Stack trace
java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
java.lang.Long.parseLong(Long.java:589)
java.lang.Long.<init>(Long.java:965)
As far i understand, tapestry is trying to pass parameter "[]" to the
method moreValues(int), which fails.
My question is why is not passing String "1" (pageNumber), which can be
casted to int?
My second question is why is even pageNumber mandatory in
PageScrollDemo.tml? If i remove params from moreValues(), i get this:
trace
Triggering event 'scroll' on PageScrollDemo:pagescroll
org.apache.tapestry5.runtime.ComponentEventExceptionFailure writing
parameter 'pageNumber' of component PageScrollDemo:pagescroll: Literal
values are not updateable.
Could somebody please explain me how to use Pagescroll?