From: <tri...@us...> - 2008-08-05 16:39:52
|
Revision: 654 http://equanda.svn.sourceforge.net/equanda/?rev=654&view=rev Author: triathlon98 Date: 2008-08-05 16:39:43 +0000 (Tue, 05 Aug 2008) Log Message: ----------- EQ-199 assure errors during onActivate() are properly handled Modified Paths: -------------- trunk/equanda-generate/src/main/velocity/t5gui/base/EditPageBase.java.vm trunk/equanda-maven-plugin/src/main/resources/archetype-resources/gui/src/main/resources/components/Layout.tml trunk/equanda-test/test-t5-gui/src/main/resources/org/equanda/test/gui/components/Layout.tml Modified: trunk/equanda-generate/src/main/velocity/t5gui/base/EditPageBase.java.vm =================================================================== --- trunk/equanda-generate/src/main/velocity/t5gui/base/EditPageBase.java.vm 2008-08-05 13:30:17 UTC (rev 653) +++ trunk/equanda-generate/src/main/velocity/t5gui/base/EditPageBase.java.vm 2008-08-05 16:39:43 UTC (rev 654) @@ -35,6 +35,7 @@ import org.apache.log4j.Logger; import org.apache.tapestry5.ComponentResources; import org.apache.tapestry5.ValidationTracker; +import org.apache.tapestry5.services.Environment; import org.apache.tapestry5.annotations.Environmental; import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.corelib.components.Form; @@ -44,8 +45,8 @@ import org.equanda.persistence.Uoid; import org.equanda.t5gui.*; import org.equanda.t5gui.services.EquandaSetterCache; +import org.equanda.tapestry5.data.MessageContainer; - /** * Base class for edit page */ @@ -64,6 +65,11 @@ @Environmental private ValidationTracker validationTracker; + private Exception keepException; + + @Inject + private Environment environment; + @Persist private SelectedSettings<T> selectedSettings; @@ -99,7 +105,7 @@ } catch ( EquandaPersistenceException epe ) { - error( epe ); + delayedError( epe ); } } @@ -122,7 +128,7 @@ } catch ( EquandaPersistenceException epe ) { - error( epe ); + delayedError( epe ); } } @@ -227,6 +233,20 @@ } /** + * Log error and display (later) on screen, returns null to allow "return delayedError()". + * Special version for use in onActivate. + * + * @param exc exception to log + * @return null + */ + public Object delayedError( Exception exc ) + { + log.warn( exc, exc ); + keepException = exc; + return null; + } + + /** * Log error and display on screen, returns null to allow "return error()" * * @param exc exception to log @@ -238,8 +258,7 @@ validationTracker.recordError( exc.getMessage() ); return null; } - - + /** * Used to find out how page is used: to edit an existing object or to create a new object * @@ -249,4 +268,17 @@ { return ( getObject() != null ); } + + void beginRender() + { + if ( null != keepException ) + { + environment.push( MessageContainer.class, new MessageContainer( keepException.getMessage() ) ); + } + } + + void endRender() + { + if ( null != keepException ) environment.pop( MessageContainer.class ); + } } Modified: trunk/equanda-maven-plugin/src/main/resources/archetype-resources/gui/src/main/resources/components/Layout.tml =================================================================== --- trunk/equanda-maven-plugin/src/main/resources/archetype-resources/gui/src/main/resources/components/Layout.tml 2008-08-05 13:30:17 UTC (rev 653) +++ trunk/equanda-maven-plugin/src/main/resources/archetype-resources/gui/src/main/resources/components/Layout.tml 2008-08-05 16:39:43 UTC (rev 654) @@ -54,6 +54,7 @@ <div> <t:form><div t:id="formSupport"> <div id="layout-main"> + <t:equanda.ValidationTrackerDelegate/> <t:errors/> <t:body/> </div> Modified: trunk/equanda-test/test-t5-gui/src/main/resources/org/equanda/test/gui/components/Layout.tml =================================================================== --- trunk/equanda-test/test-t5-gui/src/main/resources/org/equanda/test/gui/components/Layout.tml 2008-08-05 13:30:17 UTC (rev 653) +++ trunk/equanda-test/test-t5-gui/src/main/resources/org/equanda/test/gui/components/Layout.tml 2008-08-05 16:39:43 UTC (rev 654) @@ -51,6 +51,7 @@ <div> <t:form> <div id="layout-main"> + <t:equanda.ValidationTrackerDelegate/> <t:errors/> <t:body/> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |