You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Shawn Church <sh...@boxity.com> on 2005/04/06 04:58:47 UTC

RE: Locked pageRecorder

Thijs,

Since this is best suited for the Tapestry users list, I am replying back
there.

First of all, in case you don't have a copy of Tapestry in Action, I would
recommend it since it explains the rewind phase as well as the listener call
order very well.  For your specific situation, chapter 10 explains exactly
what it sounds like you are trying to do (see the Browser component).

Persistent page properties can be modified as long as you are not in the
rewind phase, so in pageBeginRender you should immediately return if
event.getRequestCycle().isRewinding() (see page 298 of TiA).  As stated, the
pageBeginRender method "is invoked before the page's recorder is committed,
while it is still able to change persistent page properties".

I've never liked the "rewind" term very well, since it implies a
reverse-order.  To me, "replay" or "re-render" or
"rebuild-my-page-state-to-match-the-form-just-submitted" makes more sense.
If a persistent page property is used to construct a form, and then the form
is submitted by a user, Tapestry must be able to reconstruct a "duplicate"
of the originally-presented form so that the newly-available input values of
the form are correctly associated with an image of the original form.  So,
by the time your form listener is called, everything appears to your
application as it should.

If you need more information, it would help to know a little more about what
exactly you are trying to do.  What "model" are you referring to?  Is that
one of your page's persistent properties?  Or is it a persistent property of
your component?  In your page specification, are the bound parameters for
your component set to direction="auto" (the "direction" attribute is going
away in the next release of Tapestry).

Shawn


-----Original Message-----
From: Thijs Suijten [mailto:t.suijten@semantica.nl]
Sent: Monday, April 04, 2005 4:47 AM
To: Tapestry development
Subject: Locked pageRecorder


I posted an issue to the users mailing list but I didn’t get a
satisfying answer so I’d like to try it here.

I've been working with Tapestry for quit a while now. I still haven't
figured out why persistent page properties cannot be modified during the
render phase. (I get a locked error)

In my case I want to do the caching/initialization in a component, this
cannot be done in the pageBeginRender because the pageBeginRender is a
listener. I don't know in what order the listeners are being called and
this causes a problem. The model is being passed to the component by a
parameter, which is initialized in the component's-parent-page
pageBeginRender. Because I don't know which pageBeginRender is called
first I get a NullPointerException, in my case the component's
pageBeginRender is being called first and then the
component's-parent-page pageBeginRender.

This results in not being able to do anything in the component's
pageBeginRender because the model is null at that point, because the
pageBeginRender is the last place I can set persistent page properties,
I have a problem.

I hope you understand my problem, english is not my native tongue so
explaining such a complex problem is difficult...

Thijs Suijten - The Netherlands.


--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.1 - Release Date: 1-4-2005


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


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


RE: Locked pageRecorder

Posted by Joerg Latteier <la...@online.de>.
While searching for the best way to modify persistent properties without
receiving "locked errors", I found that overriding renderComponent() 
works best for me for pages as well as for components:

  protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
{
    ...modify persistent properties...
    super.renderComponent(writer, cycle);
  }

The only scenario where it does not prevent you from receiving a locked
error
is, if the page is rendered is multiple times, e.g. because a user submits a
form again before receiving the result of the first submit, or when
calling the same page from multiple browser windows/tabs simultaneously.
As far as I know this is a well-known tapestry design issue and the only way

to work around this is to avoid persistent properties.
I catch these errors with customized error pages, in other areas I hide the
form buttons using javascript after the submit and show some kind of
progress
message.

Joerg


>> -----Original Message-----
>> From: Thijs Suijten [mailto:t.suijten@semantica.nl]
>> Sent: Monday, April 04, 2005 4:47 AM
>> To: Tapestry development
>> Subject: Locked pageRecorder
>> 
>> 
>> I posted an issue to the users mailing list but I didn’t get a
>> satisfying answer so I’d like to try it here.
>> 
>> I've been working with Tapestry for quit a while now. I still haven't
>> figured out why persistent page properties cannot be 
>> modified during the
>> render phase. (I get a locked error)
>> 
>> In my case I want to do the caching/initialization in a 
>> component, this
>> cannot be done in the pageBeginRender because the 
>> pageBeginRender is a
>> listener. I don't know in what order the listeners are being 
>> called and
>> this causes a problem. The model is being passed to the 
>> component by a
>> parameter, which is initialized in the component's-parent-page
>> pageBeginRender. Because I don't know which pageBeginRender is called
>> first I get a NullPointerException, in my case the component's
>> pageBeginRender is being called first and then the
>> component's-parent-page pageBeginRender.
>> 
>> This results in not being able to do anything in the component's
>> pageBeginRender because the model is null at that point, because the
>> pageBeginRender is the last place I can set persistent page 
>> properties,
>> I have a problem.
>> 
>> I hope you understand my problem, english is not my native tongue so
>> explaining such a complex problem is difficult...
>> 
>> Thijs Suijten - The Netherlands.
>> 
>> 
>> --
>> No virus found in this outgoing message.
>> Checked by AVG Anti-Virus.
>> Version: 7.0.308 / Virus Database: 266.9.1 - Release Date: 1-4-2005
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: 
>> tapestry-user-help@jakarta.apache.org
>> 
>> 


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