You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Todd O'Bryan <to...@mac.com> on 2004/04/29 05:26:19 UTC

pageBeginRender()

OK, I'm confused still...

It looks like pageBeginRender() gets called twice...once when my page 
is first created and then again when I click on a button to submit a 
response (the notorious rewind phase).

Unfortunately, I'm displaying a random object when the page is first 
accessed, then I want to pass that object to another page after the 
user submits so that I can respond to their click appropriately. 
Unfortunately, before I can assign that object to the target page, 
pageBeginRender() has already replaced it with another random object.

Which method do I implement to do something once when a page is 
created, and do I have to do anything special to make sure I'm not in 
the midst of a rewind?

Thanks,
Todd

P.S. Although beginPageRender() is marked deprecated in AbstractPage, 
it's not so marked in IPage. It probably should be.


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


Re: pageBeginRender()

Posted by Todd O'Bryan <to...@mac.com>.
Thanks!!!

For posterity, you do something like:

public void pageBeginRender(PageEvent event) {
	if (! event.getRequestCycle().isRewinding()) {
		// do your one-time first time page is rendered code here
	}
}

Note that I had to make the property I was setting persistent to avoid 
a null pointer exception.
I assume this is because when the page is rewound, all non-persistent 
objects go back to
their default state.

Thanks again,
Todd

On Apr 28, 2004, at 11:35 PM, Glen Stampoultzis wrote:

>
> You can check (using the cycle object) whether you're rewinding and 
> not create the object.
>
> At 01:26 PM 29/04/2004, you wrote:
>> OK, I'm confused still...
>>
>> It looks like pageBeginRender() gets called twice...once when my page 
>> is first created and then again when I click on a button to submit a 
>> response (the notorious rewind phase).
>>
>> Unfortunately, I'm displaying a random object when the page is first 
>> accessed, then I want to pass that object to another page after the 
>> user submits so that I can respond to their click appropriately. 
>> Unfortunately, before I can assign that object to the target page, 
>> pageBeginRender() has already replaced it with another random object.
>>
>> Which method do I implement to do something once when a page is 
>> created, and do I have to do anything special to make sure I'm not in 
>> the midst of a rewind?
>>
>> Thanks,
>> Todd
>>
>> P.S. Although beginPageRender() is marked deprecated in AbstractPage, 
>> it's not so marked in IPage. It probably should be.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>
>
> Glen Stampoultzis
> gstamp@iinet.net.au
> http://members.iinet.net.au/~gstamp/glen/


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


Re: pageBeginRender()

Posted by Glen Stampoultzis <gs...@iinet.net.au>.
You can check (using the cycle object) whether you're rewinding and not 
create the object.

At 01:26 PM 29/04/2004, you wrote:
>OK, I'm confused still...
>
>It looks like pageBeginRender() gets called twice...once when my page is 
>first created and then again when I click on a button to submit a response 
>(the notorious rewind phase).
>
>Unfortunately, I'm displaying a random object when the page is first 
>accessed, then I want to pass that object to another page after the user 
>submits so that I can respond to their click appropriately. Unfortunately, 
>before I can assign that object to the target page, pageBeginRender() has 
>already replaced it with another random object.
>
>Which method do I implement to do something once when a page is created, 
>and do I have to do anything special to make sure I'm not in the midst of 
>a rewind?
>
>Thanks,
>Todd
>
>P.S. Although beginPageRender() is marked deprecated in AbstractPage, it's 
>not so marked in IPage. It probably should be.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


Glen Stampoultzis
gstamp@iinet.net.au
http://members.iinet.net.au/~gstamp/glen/