pageValidate happens when the page is first activated in the cycle. Any annotations are also executed at this time, so @InitialValue has already done its work when pageValidate is called
pageAttached happens just after that. It only fires once per request, whether rewind or render activateExternalPage happens next, if it is an IExternalPage, so now any external parameters are populated pageBeginRender happens after that. It fires before the rewind AND before the render cycle. So yes, the first time pageBeginRender is called, your properties have not yet been updated by the rewind cycle. However, the second time pageBeginRender is called, it is just about to begin the render cycle, so all of your properties are fully populated. You can detect whether it is rewinding or rendering by calling cycle.isRewinding() within the method. So it is probably best to leave your initialization in pageBeginRender, since that is the only place you put init code which is dependant on your external params or which will occur before render cycle instead of before rewind. I wind up breaking my pageBeginRender method up into 4 stages for precisely this reason. @InitialValue("ognl:false") public abstract boolean isOnceInitialized(); public abstract void setOnceInitialized(boolean val); public final void pageBeginRender(PageEvent event) { initPage(event); if (!isOnceInitialized()) { initOnlyOnce(event); setOnceInitialized(true); } if (getRequestCycle().isRewinding()) { initForRewind(event); } else { initForRender(event); } } This is in my base page class(es). I then simply overload initPage, initOnlyOnce, initForRewind, and initForRender according to what the page requires. It just eliminates having lots of init code in the same method with conditionals to determine where the code needs to fire. --sam On 12/7/06, Martin Strand <[EMAIL PROTECTED]> wrote:
I do it in pageBeginRender. I suppose you could use pageValidate if you need it a little earlier. On Thu, 07 Dec 2006 17:20:45 +0100, Dan Adams <[EMAIL PROTECTED]> wrote: > What is the correct place to initialize a @Persisted property? > pageAttached() is too early it seems as the properties haven't been > updated but pageBeginRender() is too later since you have to update them > before rendering begins. > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]