You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Stephan Windmüller <st...@tu-dortmund.de> on 2012/03/22 10:51:27 UTC

Grid is empty after inPlaceUpdate

Hello!

In my test page consisting of a single Grid component, the source values
are constructed in the setupRender method. Sorting works fine until I
enable the inPlace option of the Grid.

After that, every time I try to sort the Grid, it displays the empty
message. I tried to update the values in onInplaceUpdate with no luck.

Does anyone know what I am missing here? And is there any documentation
about how to use the inPlace parameter?

TIA
 Stephan


Re: Grid is empty after inPlaceUpdate

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 22 Mar 2012 10:20:28 -0300, Stephan Windmüller  
<st...@tu-dortmund.de> wrote:

> On 22.03.2012 14:13, I Stephan Windmüller wrote:
>
>> Of course: https://gist.github.com/2158274
>
> Sorry, had to create a new one:
>
> https://gist.github.com/2158304

Yep, the working solution is also correct from a Tapestry philosophy  
standpoint, except for the lack of onPassivate() method. You could also  
have a getLocales() method and remove the locales field, but now it's just  
a matter of taste.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Grid is empty after inPlaceUpdate

Posted by Stephan Windmüller <st...@tu-dortmund.de>.
On 22.03.2012 14:13, I Stephan Windmüller wrote:

> Of course: https://gist.github.com/2158274

Sorry, had to create a new one:

https://gist.github.com/2158304

- Stephan


Re: Grid is empty after inPlaceUpdate

Posted by trsvax <tr...@gmail.com>.
I used to use onActivate to do initialization but I also switched to
setupRender. I also think onActivate is called when rendering links and if
for example you put a database query in it you'll do more queries than you
need.

However in this case I would not use either I'd use

@ActivationRequestParameter for the search parameters and do what Thiago
said

"I usually don't fetch the data for it in onActivate()  
or setupRender(), but in a property which is passed directly to the source  
parameter"

The problem with @Persist is if you leave the page and come back your
parameters will still be there. In most cases that's not what a user
expects. It also puts stuff in the session where request parameters are in
the url. That's always a plus to me.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Grid-is-empty-after-inPlaceUpdate-tp5585265p5586879.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Grid is empty after inPlaceUpdate

Posted by Stephan Windmüller <st...@tu-dortmund.de>.
On 23.03.2012 00:36, Bob Harner wrote:

> I suspect the advice about restricting the use of onActivate for
> activation context purposes came from
> http://jumpstart.doublenegative.com.au/jumpstart/examples/navigation/onactivateandonpassivate/3

Yes, that is most likely.

But I will take Thiago's advice about the usage of onActivate, it will
make some data handling much easier.

- Stephan


Re: Grid is empty after inPlaceUpdate

Posted by Bob Harner <bo...@gmail.com>.
I suspect the advice about restricting the use of onActivate for
activation context purposes came from
http://jumpstart.doublenegative.com.au/jumpstart/examples/navigation/onactivateandonpassivate/3

On Thu, Mar 22, 2012 at 1:08 PM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> On Thu, 22 Mar 2012 12:02:11 -0300, Stephan Windmüller
> <st...@tu-dortmund.de> wrote:
>
>> For me the advantage of this is the strict separation of code:
>> onActivate handles the activation parameters, setupRender initializes
>> all data which is needed to display the page and onPrepare handles data
>> for form display/submission.
>
>
> This is not strictly correct and your problem is an example of that.
>
>
>> Furthermore (if I remember correctly) the justification was that
>> onActivate is also called when rendering a page link, but I never tested
>> if this is true.
>
>
> This isn't correct. onPassivate() is. onActivate() is invoked when handling
> a page render or an event request.
>
>
>>> For example,  if I'm using a Grid, I usually don't fetch the data for
>>> it in onActivate() or setupRender(), but in a property which is
>>> passed directly to the source  parameter.
>>
>>
>> We have many cases where the get-method would be called multiple times
>> because we need the value during the whole setupRender process. In this
>> case we would need to cache the value in the get-method or something
>> like this. That is why we preferred the initialization at the top of
>> setupRender().
>
>
> Take a look at the @Cached annotation.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
> instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>

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


Re: Grid is empty after inPlaceUpdate

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 22 Mar 2012 12:02:11 -0300, Stephan Windmüller  
<st...@tu-dortmund.de> wrote:

> For me the advantage of this is the strict separation of code:
> onActivate handles the activation parameters, setupRender initializes
> all data which is needed to display the page and onPrepare handles data
> for form display/submission.

This is not strictly correct and your problem is an example of that.

> Furthermore (if I remember correctly) the justification was that
> onActivate is also called when rendering a page link, but I never tested
> if this is true.

This isn't correct. onPassivate() is. onActivate() is invoked when  
handling a page render or an event request.

>> For example,  if I'm using a Grid, I usually don't fetch the data for
>> it in onActivate() or setupRender(), but in a property which is
>> passed directly to the source  parameter.
>
> We have many cases where the get-method would be called multiple times
> because we need the value during the whole setupRender process. In this
> case we would need to cache the value in the get-method or something
> like this. That is why we preferred the initialization at the top of
> setupRender().

Take a look at the @Cached annotation.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Grid is empty after inPlaceUpdate

Posted by Stephan Windmüller <st...@tu-dortmund.de>.
On 22.03.2012 15:27, Thiago H. de Paula Figueiredo wrote:

>> I thought that onActivate should only be used to initialize data
>> gathered from the activation context and that other intializations
>> should be done in setupRender.
> Have you read this somewhere? I disagree. Any initialization that should  
> be needed in all requests, AJAX or not, can be done in onActivate().

It is possible that I read this somewhere but I cannot recall where.

For me the advantage of this is the strict separation of code:
onActivate handles the activation parameters, setupRender initializes
all data which is needed to display the page and onPrepare handles data
for form display/submission.

Furthermore (if I remember correctly) the justification was that
onActivate is also called when rendering a page link, but I never tested
if this is true.

> For example,  if I'm using a Grid, I usually don't fetch the data for
> it in onActivate() or setupRender(), but in a property which is
> passed directly to the source  parameter.

We have many cases where the get-method would be called multiple times
because we need the value during the whole setupRender process. In this
case we would need to cache the value in the get-method or something
like this. That is why we preferred the initialization at the top of
setupRender().

- Stephan


Re: Grid is empty after inPlaceUpdate

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 22 Mar 2012 10:13:35 -0300, Stephan Windmüller  
<st...@tu-dortmund.de> wrote:

> I thought that onActivate should only be used to initialize data
> gathered from the activation context and that other intializations
> should be done in setupRender.

Have you read this somewhere? I disagree. Any initialization that should  
be needed in all requests, AJAX or not, can be done in onActivate(). And  
don't forget that Grid with inplace updates is doing AJAX requests. In  
addition, you don't even need initialization in some cases. For example,  
if I'm using a Grid, I usually don't fetch the data for it in onActivate()  
or setupRender(), but in a property which is passed directly to the source  
parameter. Something like this:

<table t:type="Grid" t:source="users">

public List<User> getUsers() {
	return usersDao.findAll();
}

When an AJAX request is made, the setupRender event is not triggered in  
the page nor in components (unless they're inside a zone which is being  
updated).

> Of course: https://gist.github.com/2158274

It's deleted.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Grid is empty after inPlaceUpdate

Posted by Stephan Windmüller <st...@tu-dortmund.de>.
Am 22.03.2012 13:48, schrieb Thiago H. de Paula Figueiredo:

>> The search parameters come directly from the activation context. If I
>> put the initialization of the source parameter in onAcivate, all works
>> as expected, but I do not think that this is the right way.
> Why not? It's correct for me. Not the only way of doing it, but definitely  
> one of them.

I thought that onActivate should only be used to initialize data
gathered from the activation context and that other intializations
should be done in setupRender.

> Could you post your code in the versions that work and that  
> don't work?

Of course: https://gist.github.com/2158274

Regards
 Stephan


Re: Grid is empty after inPlaceUpdate

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 22 Mar 2012 09:32:35 -0300, Stephan Windmüller  
<st...@tu-dortmund.de> wrote:

> On 22.03.2012 12:18, Thiago H. de Paula Figueiredo wrote:
>
>> Or @Persist just the search parameters (if any) and do the search in  
>> every
>> request, AJAX or not.
>
> What do you mean by "every request"?
>
> The search parameters come directly from the activation context. If I
> put the initialization of the source parameter in onAcivate, all works
> as expected, but I do not think that this is the right way.

Why not? It's correct for me. Not the only way of doing it, but definitely  
one of them. Could you post your code in the versions that work and that  
don't work?

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Grid is empty after inPlaceUpdate

Posted by Stephan Windmüller <st...@tu-dortmund.de>.
On 22.03.2012 12:18, Thiago H. de Paula Figueiredo wrote:

> Or @Persist just the search parameters (if any) and do the search in every  
> request, AJAX or not.

What do you mean by "every request"?

The search parameters come directly from the activation context. If I
put the initialization of the source parameter in onAcivate, all works
as expected, but I do not think that this is the right way.

Regards
 Stephan


Re: Grid is empty after inPlaceUpdate

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 22 Mar 2012 06:53:08 -0300, Lenny Primak <lp...@hope.nyc.ny.us>  
wrote:

> Are you @Persist'ing your object where you get the data for the grid?
> The inPlaceUpdate is actually a JavaScript call, which is in a different
> thread, so if you don't @Persist, the data gets lost between requests.

Or @Persist just the search parameters (if any) and do the search in every  
request, AJAX or not.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Grid is empty after inPlaceUpdate

Posted by Stephan Windmüller <st...@tu-dortmund.de>.
On 22.03.2012 10:53, Lenny Primak wrote:

> Are you @Persist'ing your object where you get the data for the grid?

No, I want to be able to show different grids in different browser tabs.

> The inPlaceUpdate is actually a JavaScript call, which is in a different
> thread, so if you don't @Persist, the data gets lost between requests.

Is there any way to restore the values during the JavaScript call?

Regards
 Stephan


Re: Grid is empty after inPlaceUpdate

Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
Are you @Persist'ing your object where you get the data for the grid?
The inPlaceUpdate is actually a JavaScript call, which is in a different
thread, so if you don't @Persist, the data gets lost between requests.

On Mar 22, 2012, at 5:51 AM, Stephan Windmüller wrote:

> Hello!
> 
> In my test page consisting of a single Grid component, the source values
> are constructed in the setupRender method. Sorting works fine until I
> enable the inPlace option of the Grid.
> 
> After that, every time I try to sort the Grid, it displays the empty
> message. I tried to update the values in onInplaceUpdate with no luck.
> 
> Does anyone know what I am missing here? And is there any documentation
> about how to use the inPlace parameter?
> 
> TIA
> Stephan
> 


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