I am trying to use tapestry5 jquery component PageScroll for infinite scrolling.
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.RuntimeException
Coercion of [] to type java.lang.Integer (via String --> Long, Long --> Integer) failed: For input string: "[]"
java.lang.NumberFormatException
For 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.ComponentEventException
Failure writing parameter 'pageNumber' of component PageScrollDemo:pagescroll: Literal values are not updateable.
Could somebody please explain me how to use Pagescroll?
There is some documentation from the author of this component available at https://tawus.wordpress.com/2012/11/25/scrolling-pages-tapestry5-onscrollbeyond/
if you have a look at the source doc, https://github.com/got5/tapestry5-jquery/blob/master/src/main/java/org/got5/tapestry5/jquery/components/PageScroll.java you will find the following code
@Parameter(value = "literal:[]")
private Object[] context;
I guess that you get your code form the sample at https://github.com/got5/tapestry5-jquery/blob/master/src/test/resources/org/got5/tapestry5/jquery/pages/PageScroll.tml
Your error message
java.lang.RuntimeExceptionCoercion of [] to type java.lang.Integer
(via String --> Long, Long --> Integer) failed: For input string: "[]"
java.lang.NumberFormatExceptionFor input string: "[]"
come from the default value of the parameter context you have removed from the template.