Re: tapestry jquery PageScroll

2016-03-20 Thread Robert Jakeš
Thank you for reply.

I was not aware of tests for tapestry5-jquery


> 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


I manage to get it working, but now it's trying to fetch data for every
scroll.
Is there a way how to pass restrictions to the jquery script? For example
at the bottom of the page and only for scrolling down.


2016-03-20 18:14 GMT+01:00 françois facon :

> 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.
>
> see also https://tapestry.apache.org/component-parameters.html for more
> details about parameter binding.
>
> for questions related to tapestry5 jquery component, I suggest you to open
> an issue at https://github.com/got5/tapestry5-jquery/issues.
>
> 2016-03-15 10:13 GMT+01:00 Robert Jakeš :
>
> > 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 moreValues(int pageNumber) throws InterruptedException
> {
> > List values = new ArrayList();
> > int first = pageNumber * PageSize;
> > for(int i = 0; i < PageSize; ++i){
> > values.add(first + i);
> > }
> >
> > Thread.sleep(1000);
> > return values;
> > }}
> >
> > PageScrollDemo.tml
> >
> > BEGIN
> >  > zone='zone' pageNumber="1">
> >
> > ${value}
> > 
> >  > id='scroller'>END
> >
> > 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.(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?
> >
>


Re: tapestry jquery PageScroll

2016-03-20 Thread françois facon
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.

see also https://tapestry.apache.org/component-parameters.html for more
details about parameter binding.

for questions related to tapestry5 jquery component, I suggest you to open
an issue at https://github.com/got5/tapestry5-jquery/issues.

2016-03-15 10:13 GMT+01:00 Robert Jakeš :

> 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 moreValues(int pageNumber) throws InterruptedException {
> List values = new ArrayList();
> int first = pageNumber * PageSize;
> for(int i = 0; i < PageSize; ++i){
> values.add(first + i);
> }
>
> Thread.sleep(1000);
> return values;
> }}
>
> PageScrollDemo.tml
>
> BEGIN
>  zone='zone' pageNumber="1">
>
> ${value}
> 
>  id='scroller'>END
>
> 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.(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?
>