You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Hugo Palma <hu...@gmail.com> on 2008/10/07 18:47:30 UTC

Triggering a partial update on a grid

I have a search form and a grid with the results.
I'd  like to submit the form and update the grid with the filtered 
results without doing a full page refresh.

My take on this is to set the form component "zone" parameter to the 
grid zone id so that the form submit it's treated "AJAX way" and the 
submission triggers the grid zone to get updated. The form submit event 
handler method filters the search results, changes the property that the 
grid uses as datasource and returns the Grid component itself.

This strangely enough only works the first time i perform the search. 
 From there on i always get an exception when i click the search button, 
that seems to be related to the fact that the Grid doesn't acknowledge 
that the datasource size has changed. Here's the stack trace:

Caused by: java.lang.IndexOutOfBoundsException: Index: 10, Size: 10
    at java.util.ArrayList.RangeCheck(ArrayList.java:547)
    at java.util.ArrayList.get(ArrayList.java:322)
    at 
org.apache.tapestry5.internal.grid.CollectionGridDataSource.getRowValue(CollectionGridDataSource.java:111)
    at 
org.apache.tapestry5.corelib.components.Grid$CachingDataSource.getRowValue(Grid.java:324)
    at 
org.apache.tapestry5.corelib.components.GridRows.setupForRow(GridRows.java:238)
    at 
org.apache.tapestry5.corelib.components.GridRows$SetupForRow.execute(GridRows.java:70)
    at 
org.apache.tapestry5.corelib.components.GridRows$SetupForRow.execute(GridRows.java:57)
    at 
org.apache.tapestry5.corelib.components.Form.executeStoredActions(Form.java:447)

Any ideas would be most welcome.
Thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Triggering a partial update on a grid

Posted by Hugo Palma <hu...@gmail.com>.
That could be problem.
I can see that the grid is using CachingDataSource for caching the 
dataSource size. But i see no way to invalidate that cache.

Jecki wrote:
> On Wed, Oct 8, 2008 at 12:47 AM, Hugo Palma <hu...@gmail.com> wrote:
>   
>> I have a search form and a grid with the results.
>> I'd  like to submit the form and update the grid with the filtered results
>> without doing a full page refresh.
>>
>> My take on this is to set the form component "zone" parameter to the grid
>> zone id so that the form submit it's treated "AJAX way" and the submission
>> triggers the grid zone to get updated. The form submit event handler method
>> filters the search results, changes the property that the grid uses as
>> datasource and returns the Grid component itself.
>>
>> This strangely enough only works the first time i perform the search. From
>> there on i always get an exception when i click the search button, that
>> seems to be related to the fact that the Grid doesn't acknowledge that the
>> datasource size has changed. Here's the stack trace:
>>
>> Caused by: java.lang.IndexOutOfBoundsException: Index: 10, Size: 10
>>   at java.util.ArrayList.RangeCheck(ArrayList.java:547)
>>   at java.util.ArrayList.get(ArrayList.java:322)
>>   at
>> org.apache.tapestry5.internal.grid.CollectionGridDataSource.getRowValue(CollectionGridDataSource.java:111)
>>   at
>> org.apache.tapestry5.corelib.components.Grid$CachingDataSource.getRowValue(Grid.java:324)
>>   at
>> org.apache.tapestry5.corelib.components.GridRows.setupForRow(GridRows.java:238)
>>   at
>> org.apache.tapestry5.corelib.components.GridRows$SetupForRow.execute(GridRows.java:70)
>>   at
>> org.apache.tapestry5.corelib.components.GridRows$SetupForRow.execute(GridRows.java:57)
>>   at
>> org.apache.tapestry5.corelib.components.Form.executeStoredActions(Form.java:447)
>>
>>     
>
> from the above stack trace seems like the DataSource was cached right?
> could that be the problem?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>   

Re: Triggering a partial update on a grid

Posted by Jecki <je...@gmail.com>.
On Wed, Oct 8, 2008 at 12:47 AM, Hugo Palma <hu...@gmail.com> wrote:
> I have a search form and a grid with the results.
> I'd  like to submit the form and update the grid with the filtered results
> without doing a full page refresh.
>
> My take on this is to set the form component "zone" parameter to the grid
> zone id so that the form submit it's treated "AJAX way" and the submission
> triggers the grid zone to get updated. The form submit event handler method
> filters the search results, changes the property that the grid uses as
> datasource and returns the Grid component itself.
>
> This strangely enough only works the first time i perform the search. From
> there on i always get an exception when i click the search button, that
> seems to be related to the fact that the Grid doesn't acknowledge that the
> datasource size has changed. Here's the stack trace:
>
> Caused by: java.lang.IndexOutOfBoundsException: Index: 10, Size: 10
>   at java.util.ArrayList.RangeCheck(ArrayList.java:547)
>   at java.util.ArrayList.get(ArrayList.java:322)
>   at
> org.apache.tapestry5.internal.grid.CollectionGridDataSource.getRowValue(CollectionGridDataSource.java:111)
>   at
> org.apache.tapestry5.corelib.components.Grid$CachingDataSource.getRowValue(Grid.java:324)
>   at
> org.apache.tapestry5.corelib.components.GridRows.setupForRow(GridRows.java:238)
>   at
> org.apache.tapestry5.corelib.components.GridRows$SetupForRow.execute(GridRows.java:70)
>   at
> org.apache.tapestry5.corelib.components.GridRows$SetupForRow.execute(GridRows.java:57)
>   at
> org.apache.tapestry5.corelib.components.Form.executeStoredActions(Form.java:447)
>

from the above stack trace seems like the DataSource was cached right?
could that be the problem?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Triggering a partial update on a grid

Posted by Hugo Palma <hu...@gmail.com>.
Yep, i have it implemented like that. Forgot to rollback some changes 
that i tried to make this work before putting the code in the post. Sorry.
With a zone just outside the grid and setting the form to update it i'm 
still getting the exception.

Thiago H. de Paula Figueiredo wrote:
> Em Tue, 07 Oct 2008 15:42:26 -0300, Hugo Palma 
> <hu...@gmail.com> escreveu:
>
>> I thought so too, but i'm starting to think there is one.
>> Here's some of the code in hope someone will spot something wrong:
>>
>> <div t:type="form" t:id="filterForm" zone="processGrid">
>>             <div t:type="grid" t:id="processGrid" source="processes"
>
> Maybe not related to your problem, but the zone parameter of the Form 
> component must be the id of a *zone*. You're passing it the id of a 
> *grid*. I would try to put the grid inside a zone and then update the 
> zone. ;)
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Triggering a partial update on a grid

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 07 Oct 2008 15:42:26 -0300, Hugo Palma <hu...@gmail.com>  
escreveu:

> I thought so too, but i'm starting to think there is one.
> Here's some of the code in hope someone will spot something wrong:
>
> <div t:type="form" t:id="filterForm" zone="processGrid">
>             <div t:type="grid" t:id="processGrid" source="processes"

Maybe not related to your problem, but the zone parameter of the Form  
component must be the id of a *zone*. You're passing it the id of a  
*grid*. I would try to put the grid inside a zone and then update the  
zone. ;)

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
Consultor, desenvolvedor e instrutor em Java
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Triggering a partial update on a grid

Posted by Hugo Palma <hu...@gmail.com>.
I thought so too, but i'm starting to think there is one.
Here's some of the code in hope someone will spot something wrong:

template:
<div t:type="form" t:id="filterForm" zone="processGrid">
       
       <!-- the filter inputs and stuff -->
            <div t:type="buttons/genericbutton" label="message:filter" 
submit="true"/>
            <div t:type="eventlink" event="linkTest" 
zone="processGrid">Search</div>

            <div t:type="grid" t:id="processGrid" source="processes" 
inplace="true" rowsPerPage="prop:gridRowsPerPage" row="currentProcess" 
rowClass="rowClass"
                 exclude="${message:proccessListExclusionColumns}" 
reorder="${message:proccessListColumnOrder}"/>
    </div>

on the class:

@OnEvent(value = "submit", component = "filterForm")
    Grid filter() {
        processes.remove(0);
        return processGrid;
    }

    Grid linkTest() {
        processes.remove(0);
        return processGrid;
    }

If i press the eventlink eveything goes fine, if i use the submit button 
i get the exception.

Thiago H. de Paula Figueiredo wrote:
> Em Tue, 07 Oct 2008 15:22:03 -0300, Hugo Palma 
> <hu...@gmail.com> escreveu:
>
>> What's the difference between using the form submit with a zone and 
>> using an event link besides the form parameters not getting updated ?
>
> AFAIK, none.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Triggering a partial update on a grid

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 07 Oct 2008 15:22:03 -0300, Hugo Palma <hu...@gmail.com>  
escreveu:

> What's the difference between using the form submit with a zone and  
> using an event link besides the form parameters not getting updated ?

AFAIK, none.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
Consultor, desenvolvedor e instrutor em Java
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Triggering a partial update on a grid

Posted by Hugo Palma <hu...@gmail.com>.
I had thought of that.
But all the form parameters are persisted and i have debugged the 
application and the grid source parameter has the correct size. Only the 
grid doesn't seem to be aware of it.

I just found out that if i use an eventlink component to trigger the 
update instead of the form submit it works just fine. Obviously the form 
parameters aren't updated but i put some code on the event handler that 
filters the source anyway. No exception this way.

What's the difference between using the form submit with a zone and 
using an event link besides the form parameters not getting updated ?

Thiago H. de Paula Figueiredo wrote:
> Em Tue, 07 Oct 2008 13:47:30 -0300, Hugo Palma 
> <hu...@gmail.com> escreveu:
>
>> Caused by: java.lang.IndexOutOfBoundsException: Index: 10, Size: 10
>
> Take a look at the collection returned to the Grid source parameter in 
> the second request. One common error is to not @Persist the form 
> parameters. Then, when you request the n+1 page, the form parameters 
> are lost and the search made is not the same as the first one.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Triggering a partial update on a grid

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 07 Oct 2008 13:47:30 -0300, Hugo Palma <hu...@gmail.com>  
escreveu:

> Caused by: java.lang.IndexOutOfBoundsException: Index: 10, Size: 10

Take a look at the collection returned to the Grid source parameter in the  
second request. One common error is to not @Persist the form parameters.  
Then, when you request the n+1 page, the form parameters are lost and the  
search made is not the same as the first one.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
Consultor, desenvolvedor e instrutor em Java
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org