From 1376b2db3622796d6bb443249f5167cee5fc1558 Mon Sep 17 00:00:00 2001 From: sb Date: Fri, 17 Apr 2009 09:38:46 +0000 Subject: [PATCH] bug 2792 : Reinstated the calls to the deprecated Before- and AfterUpdateHooks, and also to the deprecated BeforeDeletionHook. I am not entirely happy with this solution, which looks ugly. Note that currently the Before- and AfterUpdateHooks are only called (in the auto-generated controller) for the principal record of a form, and not for any auxiliary records. It's possible that the hooks should also be called for these. This isn't really satisfactory - it makes for ugly and prolix code - and a better solution is desirable. More thought needed. --- transforms/adl2controllerclasses.xslt | 62 +++++++++++++++------------ 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/transforms/adl2controllerclasses.xslt b/transforms/adl2controllerclasses.xslt index 58dc1c1..97bcdb0 100755 --- a/transforms/adl2controllerclasses.xslt +++ b/transforms/adl2controllerclasses.xslt @@ -9,8 +9,8 @@ Transform ADL into (partial) controller classes $Author: sb $ - $Revision: 1.30 $ - $Date: 2009-03-25 11:52:51 $ + $Revision: 1.31 $ + $Date: 2009-04-17 09:38:46 $ --> - + @@ -70,7 +70,7 @@ // // Automatically generated abstract super class for controllers for the // application; generated using - // adl2controllerclasses.xslt version + // adl2controllerclasses.xslt version // // // @@ -180,7 +180,7 @@ // // Controller for auto-generated forms for editing s // Automatically generated from application description using - // adl2controllerclasses.xslt version + // adl2controllerclasses.xslt version // // This file is automatically generated; DO NOT EDIT IT. // @@ -279,10 +279,10 @@ if ( == null || == 0 ){ = new Message(); - hibernator.Save( ); + hibernator.SaveOrUpdate( ); } - hibernator.Save( instance); + hibernator.SaveOrUpdate( instance); } hibernator.Flush(); @@ -412,7 +412,7 @@ if ( mess == null) { mess = new Message(); } - hibernator.Save( mess); + hibernator.SaveOrUpdate( mess); Translation trans = mess.GetTranslationObject( locale, hibernator); if ( trans == null) { @@ -420,7 +420,7 @@ } trans.MessageText = Form[""]; record. = mess; - hibernator.Save( trans); + hibernator.SaveOrUpdate( trans); } @@ -586,13 +586,13 @@ ; if ( oldparent != null) { oldparent..Remove( item); - hibernator.Save( oldparent); + hibernator.SaveOrUpdate( oldparent); } /* then add it to my */ record..Add( item); = record; - hibernator.Save( item); + hibernator.SaveOrUpdate( item); } } /* foreach ( string index... */ } /* if ( Form.GetValues( "") != null) */ @@ -602,12 +602,17 @@ - /* write the record to the database, in order to guarantee we have a valid key */ - hibernator.Save(record); - hibernator.Flush(); - tx.Commit(); + /* write the record to the database, in order to guarantee we have a valid key */ + /* 20090416 we have a significant problem in that the ILifecycle interface is not + doing what we expect - or, at least, not consistently! + Reinstating the before- and after- update hooks */ + record.BeforeUpdateHook( hibernator); + hibernator.SaveOrUpdate(record); + record.AfterUpdateHook( hibernator); + + tx.Commit(); - messages.Add( ""); + messages.Add( ""); } /* try actually commit */ catch ( Exception any) { messages.Add( ""); @@ -662,17 +667,18 @@ { record = FetchRecord( hibernator); - if ( record != null) - { - hibernator.Delete( record); - hibernator.Flush(); - } - else - { - throw new ApplicationException( "No such record?"); - } - } - + if ( record != null) + { + record.BeforeDeleteHook( hibernator); + hibernator.Delete( record); + hibernator.Flush(); + } + else + { + throw new ApplicationException( "No such record?"); + } + } + Redirect( ""); @@ -1297,4 +1303,4 @@ .UniqueResult<>() - + \ No newline at end of file