Re: is there a @BootStrap annotation for methods ?
@PageLoaded or pageLoaded() This is invoked once when the page is first constructed. On Thu, Dec 27, 2012 at 9:32 AM, Ken in Nashua kcola...@live.com wrote: I have a page and I only want to do certain things during bootstrap... not specifically setupRender or onActivate Thanks in advance -- Howard M. Lewis Ship Creator of Apache Tapestry The source for Tapestry training, mentoring and support. Contact me to learn how I can get you up and productive in Tapestry fast! (971) 678-5210 http://howardlewisship.com
RE: is there a @BootStrap annotation for methods ?
Thanks for tryin... my properties are @persistent @PageLoaded public void pageLoaded() { //if (itemsPerPage == null) if (securityService.getSubject().isAuthenticated()) itemsPerPage = getLayout().getItemsPerPage(); else itemsPerPage = 5; //if (tableColumns == null) if (securityService.getSubject().isAuthenticated()) tableColumns = getLayout().getTableColumns(); else tableColumns = 3; } An unexpected application exception has occurred.org.apache.tapestry5.ioc.internal.OperationExceptionError persisting field Home:itemsPerPage: Persistent fields may not be updated until after the page has finished loading. This may be due to a persistent field with a default value. The default value should be removed.traceConstructing instance of page class org.tynamo.examples.hibernatesecurity.pages.Homeorg.apache.tapestry5.ioc.internal.util.TapestryExceptionError persisting field Home:itemsPerPage: Persistent fields may not be updated until after the page has finished loading. This may be due to a persistent field with a default value. The default value should be removed.java.lang.RuntimeExceptionPersistent fields may not be updated until after the page has finished loading. This may be due to a persistent field with a default value. The default value should be removed.Filter stack frames Stack trace org.apache.tapestry5.internal.structure.PageImpl.persistFieldChange(PageImpl.java:254) org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.persistFieldChange(InternalComponentResourcesImpl.java:324) org.apache.tapestry5.internal.transform.PersistWorker$PersistentFieldConduit.set(PersistWorker.java:64) org.tynamo.examples.hibernatesecurity.pages.Home.conduit_set_itemsPerPage(Home.java) org.tynamo.examples.hibernatesecurity.pages.Home.pageLoaded(Home.java:137) org.tynamo.examples.hibernatesecurity.pages.Home$Shim_52076d740eb
RE: is there a @BootStrap annotation for methods ?
Well I cannot take this the whole mile... I have two persistent properties and just trying to persist them on subsequent authentications from the database. and I cant I beat these three routines to death. The afterRender works beautiful. I have never had luck with the init cycle and setupRender. I believe in stateless computing but a while ago I could not get anything working unless these properties were @Persistent If anyone wants to give this logic a whirl I will try anything. Home.JAVA @PageLoaded public void pageLoaded() { } @SetupRender public void setupRender() { if (itemsPerPage == null) { if (securityService.getSubject().isAuthenticated()) itemsPerPage = getLayout().getItemsPerPage(); else itemsPerPage = 5; } if (tableColumns == null) { if (securityService.getSubject().isAuthenticated()) tableColumns = getLayout().getTableColumns(); else tableColumns = 3; } if (cursor == null) { cursor = new Integer(0); } } @Log @CommitAfter @AfterRender public void afterRender() { AdminLayout adminLayout; if ( securityService.getSubject().isAuthenticated() ) if (applicationStateManager.exists(AdminLayout.class)) { adminLayout = applicationStateManager.get(AdminLayout.class); adminLayout.setItemsPerPage(itemsPerPage); adminLayout.setTableColumns(tableColumns); persistenceService.save(adminLayout); } }
RE: is there a @BootStrap annotation for methods ?
My main catching issue being on login... my persistent properties are null... and I can predictably load them from the database so i go ahead and use my app... then i decide to click logout button... app is still running though... just unauthenticated... so I go ahead and click login link... AND... on login... my persistent properties are NOT null (since it isnt bootstrap) ... and I cant load them from the database because my condition for loading from the database is the null check... so it takes what they floated to be after logout... which is NOT what was persisted by the authenticated user. So my subsequent logins are not making it past this logic. I need a new condition other than the null check. Might anyone know what my condition may be? in order to persist properties like these from/to to/from the database? like I said the afterRender works like abreeze Thank You
Re: is there a @BootStrap annotation for methods ?
Hi, @Persist defaults to session storage, it sounds like you are not discarding your session on logout and/or not always creating a new session on (re)login. -- Chris On Thu, Dec 27, 2012 at 7:28 PM, Ken in Nashua kcola...@live.com wrote: My main catching issue being on login... my persistent properties are null... and I can predictably load them from the database so i go ahead and use my app... then i decide to click logout button... app is still running though... just unauthenticated... so I go ahead and click login link... AND... on login... my persistent properties are NOT null (since it isnt bootstrap) ... and I cant load them from the database because my condition for loading from the database is the null check... so it takes what they floated to be after logout... which is NOT what was persisted by the authenticated user. So my subsequent logins are not making it past this logic. I need a new condition other than the null check. Might anyone know what my condition may be? in order to persist properties like these from/to to/from the database? like I said the afterRender works like abreeze Thank You
RE: is there a @BootStrap annotation for methods ?
Thanks Chris, I will think about that. Good practice anyway... it may be the condition case I am looking to operate. - cheers Ken