in relation to this thread - and specifically in relation to using pageAttached() to initialise p[age fields - I raised the following possible bug the other day, https://issues.apache.org/jira/browse/TAP5-374
I was wondering if this was something anyone else had noticed/reproduced? On Fri, 2008-11-21 at 12:32 -0800, Eric Ma wrote: > Thanks for your reply. I have a follow up question: > > For @Persist field, when and how does variable binding (from HTTP > session-cached value) happen? > > Let me explain: > > Previously, when I use inline (or constructor-based) variable > initialization, although I don't know how the magic works, I am guaranteed > that only the first time a component/page object is instantiated, the > @Persist field is populated with the initial value. Subsequently when the > component/page object is retrieved from the object pool and re-used, it is > not the initial value, but the session-cached value, that is associated with > the variable. This is important because the field value might have changed > due to user action between the object instantiation and re-use. > > If I have to assign value explicitly in @SetupRender, since that method is > always called by Tapestry whether this is a new or re-used object instance, > to ensure the session-cached value is bound to the filed, do I have to do > (can we assume this is how T5 actually work behind the scene)? > > @SetupRender () { > void initializeField() { > if(session.getAttribute("persistedFieldName") == null) { > myPersistedField = "some initial value"; > } > } > > , which has 2 major problems: > > 1. I have to touch HttpSession, something that T5 makes every effort to hide > from me. > 2. Can I assume the session key is actually the session key. What if the T5 > internal implementation changes tomorrow? > > > > Marcel Sammut wrote: > > > > I had the same problem when moving to 5.0.16. It was pretty simple for > > me, since what I was doing was initializing my persistant variables in the > > declaration. What I did was move the initialization to the SetupRender > > phase of the cycle. > > > > For example: > > @Persist > > private int count = 0; > > > > became: > > @Persist > > private int count; > > @SetupRender > > void setupRender() { > > count = 0; > > } > > > > Hope that works for you too. > > Cheers, > > Marcel > > > > > -- SU3 Analytics Ltd The Print House 18 Ashwin Street E8 3DL London Tel: +44 (0) 20 3051 8637 Fax: +44 (0) 20 8196 2215 Mob: +44 (0) 79 7431 0685 www.su3analytics.com SU3 Analytics Ltd is a company registered in England and Wales under company number 06639473 at registered address 61b Oxford Gardens, London W10 5UJ, United Kingdom. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]