You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by ljnb01 <im...@gmail.com> on 2009/07/15 23:21:19 UTC

java.util.NoSuchElementException when using FormTable/Sort

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.

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

Posted by Bob Schellink <sa...@gmail.com>.
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

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

Posted by ljnb01 <im...@gmail.com>.
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<sa...@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...@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/
>>
> 
> 


-----
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-tp3265887p3275433.html
Sent from the click-user mailing list archive at Nabble.com.

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

Posted by Malcolm Edgar <ma...@gmail.com>.
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<sa...@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...@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/
>

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

Posted by Bob Schellink <sa...@gmail.com>.
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...@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/