java.util.NoSuchElementException when using FormTable/Sort

5 messages Options
Embed this post
Permalink
ljnb01

java.util.NoSuchElementException when using FormTable/Sort

Reply Threaded More More options
Print post
Permalink
Hi,

I am using Click Framework deployed in Glassfish. I followed the example in click-examples's Large Dataset Demo, but used FormTable.

All works OK but only if I sort the column or sometimes click next page I got an exception. The "Large Dataset demo" did not show a FormTable with sorting features, it is simple of "table type without sorting enabled.

So how can I fix this bug in a large dataset FormTable with sorting enabled? Or can it be done? Any examples? I thought this is very common for many commercial apps but did not find any examples. Thanks.

----- Error messages -----------

[#|2009-07-15T16:59:06.602-0400|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=26;_ThreadName=httpSSLWorkerThread-80-0;_RequestID=39cb07ae-3250-4192-b8f2-9f4cdbc95729;|ApplicationDispatcher[/osbmui] PWC1231: Servlet.service() for servlet jsp threw exception
java.util.NoSuchElementException
        at java.util.AbstractList$Itr.next(AbstractList.java:350)
        at java.util.Collections.sort(Collections.java:162)
        at org.apache.click.control.Table.sortRowList(Table.java:1778)
        at org.apache.click.control.Table.render(Table.java:1344)
        at org.apache.click.extras.control.FormTable.render(FormTable.java:605)
        at org.apache.click.control.AbstractControl.toString(AbstractControl.java:833)
        at com.sun.el.lang.ELSupport.coerceToString(ELSupport.java:341)
        at com.sun.el.lang.ELSupport.coerceToType(ELSupport.java:351)
        at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:209)

Bob Schellink-2

Re: java.util.NoSuchElementException when using FormTable/Sort

Reply Threaded More More options
Print post
Permalink
Hi Jeff,

The demo uses a trick to make the List size bigger than what it really
is. This breaks the List contract though so not all List methods work
as expected. Sorting is one of them.

The real issue is that Table should not attempt to sort the list
because it does not have access to all the rows.

Since you are lazily loading the rows for the specified page you are
also responsible to ensure the data is sorted, most probably using an
SQL ORDER BY clause.

To get around the fact that Table tries to sort the rows you can do this:

  public void onInit() {
    Table table = new Table() {

      // Override sortRowList to do nothing
      protected void sortRowList() {
      }
    }
  }

Will this work for you?

We should probably look at ways to make this setup easier in a future release.

kind regards

bob

On 7/15/09, ljnb01 <[hidden email]> wrote:

>
> Hi,
>
> I am using Click Framework deployed in Glassfish. I followed the example in
> click-examples's Large Dataset Demo, but used FormTable.
>
> All works OK but only if I sort the column or sometimes click next page I
> got an exception. The "Large Dataset demo" did not show a FormTable with
> sorting features, it is simple of "table type without sorting enabled.
>
> So how can I fix this bug in a large dataset FormTable with sorting enabled?
> Or can it be done? Any examples? I thought this is very common for many
> commercial apps but did not find any examples. Thanks.
>
> ----- Error messages -----------
>
> [#|2009-07-15T16:59:06.602-0400|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=26;_ThreadName=httpSSLWorkerThread-80-0;_RequestID=39cb07ae-3250-4192-b8f2-9f4cdbc95729;|ApplicationDispatcher[/osbmui]
> PWC1231: Servlet.service() for servlet jsp threw exception
> java.util.NoSuchElementException
>         at java.util.AbstractList$Itr.next(AbstractList.java:350)
>         at java.util.Collections.sort(Collections.java:162)
>         at org.apache.click.control.Table.sortRowList(Table.java:1778)
>         at org.apache.click.control.Table.render(Table.java:1344)
>         at
> org.apache.click.extras.control.FormTable.render(FormTable.java:605)
>         at
> org.apache.click.control.AbstractControl.toString(AbstractControl.java:833)
>         at com.sun.el.lang.ELSupport.coerceToString(ELSupport.java:341)
>         at com.sun.el.lang.ELSupport.coerceToType(ELSupport.java:351)
>         at
> com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:209)
>
>
>
> -----
> http://blogs.dengsoft.com/index.php/tech/ Java Technology Blog
> --
> View this message in context:
> http://n2.nabble.com/java.util.NoSuchElementException-when-using-FormTable-Sort-tp3265887p3265887.html
> Sent from the click-user mailing list archive at Nabble.com.
>


--
http://incubator.apache.org/click/
Malcolm Edgar-2

Re: java.util.NoSuchElementException when using FormTable/Sort

Reply Threaded More More options
Print post
Permalink
You can also set the table as sorted so it does not attempt to sort the column.

regards Malcolm Edgar

On Thu, Jul 16, 2009 at 6:57 PM, Bob Schellink<[hidden email]> wrote:

> Hi Jeff,
>
> The demo uses a trick to make the List size bigger than what it really
> is. This breaks the List contract though so not all List methods work
> as expected. Sorting is one of them.
>
> The real issue is that Table should not attempt to sort the list
> because it does not have access to all the rows.
>
> Since you are lazily loading the rows for the specified page you are
> also responsible to ensure the data is sorted, most probably using an
> SQL ORDER BY clause.
>
> To get around the fact that Table tries to sort the rows you can do this:
>
>  public void onInit() {
>    Table table = new Table() {
>
>      // Override sortRowList to do nothing
>      protected void sortRowList() {
>      }
>    }
>  }
>
> Will this work for you?
>
> We should probably look at ways to make this setup easier in a future release.
>
> kind regards
>
> bob
>
> On 7/15/09, ljnb01 <[hidden email]> wrote:
>>
>> Hi,
>>
>> I am using Click Framework deployed in Glassfish. I followed the example in
>> click-examples's Large Dataset Demo, but used FormTable.
>>
>> All works OK but only if I sort the column or sometimes click next page I
>> got an exception. The "Large Dataset demo" did not show a FormTable with
>> sorting features, it is simple of "table type without sorting enabled.
>>
>> So how can I fix this bug in a large dataset FormTable with sorting enabled?
>> Or can it be done? Any examples? I thought this is very common for many
>> commercial apps but did not find any examples. Thanks.
>>
>> ----- Error messages -----------
>>
>> [#|2009-07-15T16:59:06.602-0400|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=26;_ThreadName=httpSSLWorkerThread-80-0;_RequestID=39cb07ae-3250-4192-b8f2-9f4cdbc95729;|ApplicationDispatcher[/osbmui]
>> PWC1231: Servlet.service() for servlet jsp threw exception
>> java.util.NoSuchElementException
>>         at java.util.AbstractList$Itr.next(AbstractList.java:350)
>>         at java.util.Collections.sort(Collections.java:162)
>>         at org.apache.click.control.Table.sortRowList(Table.java:1778)
>>         at org.apache.click.control.Table.render(Table.java:1344)
>>         at
>> org.apache.click.extras.control.FormTable.render(FormTable.java:605)
>>         at
>> org.apache.click.control.AbstractControl.toString(AbstractControl.java:833)
>>         at com.sun.el.lang.ELSupport.coerceToString(ELSupport.java:341)
>>         at com.sun.el.lang.ELSupport.coerceToType(ELSupport.java:351)
>>         at
>> com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:209)
>>
>>
>>
>> -----
>> http://blogs.dengsoft.com/index.php/tech/ Java Technology Blog
>> --
>> View this message in context:
>> http://n2.nabble.com/java.util.NoSuchElementException-when-using-FormTable-Sort-tp3265887p3265887.html
>> Sent from the click-user mailing list archive at Nabble.com.
>>
>
>
> --
> http://incubator.apache.org/click/
>
ljnb01

Re: java.util.NoSuchElementException when using FormTable/Sort

Reply Threaded More More options
Print post
Permalink
Thanks Malcolm for your suggestions. I tried another approach to hack into get method of the inner class "DataProvider" by adding the following statement:

realIndex = realIndex<0 ? 0 : realIndex;

It looks like working but I need more test. I use DN SQL query to handle sorting and filtering.

BTW, how can I contribute to the project? What procedure it is like to get privilieges and check-in changes?

Thanks a lot.

Jeff

Malcolm Edgar-2 wrote:
You can also set the table as sorted so it does not attempt to sort the column.

regards Malcolm Edgar

On Thu, Jul 16, 2009 at 6:57 PM, Bob Schellink<sabob1@gmail.com> wrote:
> Hi Jeff,
>
> The demo uses a trick to make the List size bigger than what it really
> is. This breaks the List contract though so not all List methods work
> as expected. Sorting is one of them.
>
> The real issue is that Table should not attempt to sort the list
> because it does not have access to all the rows.
>
> Since you are lazily loading the rows for the specified page you are
> also responsible to ensure the data is sorted, most probably using an
> SQL ORDER BY clause.
>
> To get around the fact that Table tries to sort the rows you can do this:
>
>  public void onInit() {
>    Table table = new Table() {
>
>      // Override sortRowList to do nothing
>      protected void sortRowList() {
>      }
>    }
>  }
>
> Will this work for you?
>
> We should probably look at ways to make this setup easier in a future release.
>
> kind regards
>
> bob
>
> On 7/15/09, ljnb01 <im.jeff2008@gmail.com> wrote:
>>
>> Hi,
>>
>> I am using Click Framework deployed in Glassfish. I followed the example in
>> click-examples's Large Dataset Demo, but used FormTable.
>>
>> All works OK but only if I sort the column or sometimes click next page I
>> got an exception. The "Large Dataset demo" did not show a FormTable with
>> sorting features, it is simple of "table type without sorting enabled.
>>
>> So how can I fix this bug in a large dataset FormTable with sorting enabled?
>> Or can it be done? Any examples? I thought this is very common for many
>> commercial apps but did not find any examples. Thanks.
>>
>> ----- Error messages -----------
>>
>> [#|2009-07-15T16:59:06.602-0400|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=26;_ThreadName=httpSSLWorkerThread-80-0;_RequestID=39cb07ae-3250-4192-b8f2-9f4cdbc95729;|ApplicationDispatcher[/osbmui]
>> PWC1231: Servlet.service() for servlet jsp threw exception
>> java.util.NoSuchElementException
>>         at java.util.AbstractList$Itr.next(AbstractList.java:350)
>>         at java.util.Collections.sort(Collections.java:162)
>>         at org.apache.click.control.Table.sortRowList(Table.java:1778)
>>         at org.apache.click.control.Table.render(Table.java:1344)
>>         at
>> org.apache.click.extras.control.FormTable.render(FormTable.java:605)
>>         at
>> org.apache.click.control.AbstractControl.toString(AbstractControl.java:833)
>>         at com.sun.el.lang.ELSupport.coerceToString(ELSupport.java:341)
>>         at com.sun.el.lang.ELSupport.coerceToType(ELSupport.java:351)
>>         at
>> com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:209)
>>
>>
>>
>> -----
>> http://blogs.dengsoft.com/index.php/tech/ Java Technology Blog
>> --
>> View this message in context:
>> http://n2.nabble.com/java.util.NoSuchElementException-when-using-FormTable-Sort-tp3265887p3265887.html
>> Sent from the click-user mailing list archive at Nabble.com.
>>
>
>
> --
> http://incubator.apache.org/click/
>
Bob Schellink-2

Re: java.util.NoSuchElementException when using FormTable/Sort

Reply Threaded More More options
Print post
Permalink
Hi Jeff,

ljnb01 wrote:
>
> BTW, how can I contribute to the project? What procedure it is like to get
> privilieges and check-in changes?


See this thread: http://markmail.org/thread/pxlpb3ovnknbgq4m

kind regards

bob