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.
This commit is contained in:
		
							parent
							
								
									124a10b8cc
								
							
						
					
					
						commit
						1376b2db36
					
				
					 1 changed files with 34 additions and 28 deletions
				
			
		| 
						 | 
				
			
			@ -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 $
 | 
			
		||||
  -->
 | 
			
		||||
 | 
			
		||||
<!-- WARNING WARNING WARNING: Do NOT reformat this file! 
 | 
			
		||||
| 
						 | 
				
			
			@ -47,7 +47,7 @@
 | 
			
		|||
	<xsl:param name="entityns" select="Unset"/>
 | 
			
		||||
	<!-- Whether to authenticate at application or at database layer. 
 | 
			
		||||
    If not 'Application', then 'Database'. -->
 | 
			
		||||
	<xsl:param name="authentication-layer" select="'Application'"/>
 | 
			
		||||
	<xsl:param name="authentication-layer" select="Application"/>
 | 
			
		||||
 | 
			
		||||
	<!-- the name and version of the product being built -->
 | 
			
		||||
	<xsl:param name="product-version" select="'Application Description Language Framework'"/>
 | 
			
		||||
| 
						 | 
				
			
			@ -70,7 +70,7 @@
 | 
			
		|||
		//
 | 
			
		||||
		//  Automatically generated abstract super class for controllers for the
 | 
			
		||||
		//	<xsl:value-of select="/adl:application/@name"/> application; generated using
 | 
			
		||||
		//  adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.30 $', 10)"/>
 | 
			
		||||
		//  adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.31 $', 10)"/>
 | 
			
		||||
		//
 | 
			
		||||
		//  <xsl:value-of select="/adl:application/@revision"/>
 | 
			
		||||
		//
 | 
			
		||||
| 
						 | 
				
			
			@ -180,7 +180,7 @@
 | 
			
		|||
		//
 | 
			
		||||
		//  Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s
 | 
			
		||||
		//  Automatically generated from application description using
 | 
			
		||||
		//  adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.30 $', 10)"/>
 | 
			
		||||
		//  adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.31 $', 10)"/>
 | 
			
		||||
		//
 | 
			
		||||
		//  This file is automatically generated; DO NOT EDIT IT.
 | 
			
		||||
		//
 | 
			
		||||
| 
						 | 
				
			
			@ -279,10 +279,10 @@
 | 
			
		|||
			<xsl:for-each select="adl:property[@type='message']">
 | 
			
		||||
				if ( <xsl:value-of select="concat( 'instance.', @name)"/> == null || <xsl:value-of select="concat( 'instance.', @name, '.MessageId')"/> == 0 ){
 | 
			
		||||
				<xsl:value-of select="concat( 'instance.', @name)"/> = new Message();
 | 
			
		||||
				hibernator.Save( <xsl:value-of select="concat( 'instance.', @name)"/>);
 | 
			
		||||
				hibernator.SaveOrUpdate( <xsl:value-of select="concat( 'instance.', @name)"/>);
 | 
			
		||||
				}
 | 
			
		||||
			</xsl:for-each>
 | 
			
		||||
			hibernator.Save( instance);
 | 
			
		||||
			hibernator.SaveOrUpdate( instance);
 | 
			
		||||
			}
 | 
			
		||||
			hibernator.Flush();
 | 
			
		||||
			<xsl:if test="adl:list[@name='list']">
 | 
			
		||||
| 
						 | 
				
			
			@ -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["<xsl:value-of select="concat( 'instance.', @name)"/>"];
 | 
			
		||||
					record.<xsl:value-of select="@name"/> = mess;
 | 
			
		||||
					hibernator.Save( trans);
 | 
			
		||||
					hibernator.SaveOrUpdate( trans);
 | 
			
		||||
					}
 | 
			
		||||
				</xsl:for-each>
 | 
			
		||||
			</xsl:if>
 | 
			
		||||
| 
						 | 
				
			
			@ -586,13 +586,13 @@
 | 
			
		|||
				<xsl:value-of select="concat( 'item.', $foreignkey)"/>;
 | 
			
		||||
				if ( oldparent != null) {
 | 
			
		||||
				oldparent.<xsl:value-of select="@name"/>.Remove( item);
 | 
			
		||||
				hibernator.Save( oldparent);
 | 
			
		||||
				hibernator.SaveOrUpdate( oldparent);
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				/* then add it to my <xsl:value-of select="@name"/> */
 | 
			
		||||
				record.<xsl:value-of select="@name"/>.Add( item);
 | 
			
		||||
				<xsl:value-of select="concat( 'item.', $foreignkey)"/> = record;
 | 
			
		||||
				hibernator.Save( item);
 | 
			
		||||
				hibernator.SaveOrUpdate( item);
 | 
			
		||||
				}
 | 
			
		||||
				} /* foreach ( string index... */
 | 
			
		||||
				} /* if ( Form.GetValues( "<xsl:value-of select="concat( 'instance.', @name)"/>") != null) */
 | 
			
		||||
| 
						 | 
				
			
			@ -603,8 +603,13 @@
 | 
			
		|||
			</xsl:for-each>
 | 
			
		||||
 | 
			
		||||
      /* write the record to the database, in order to guarantee we have a valid key */
 | 
			
		||||
			hibernator.Save(record);
 | 
			
		||||
			hibernator.Flush();
 | 
			
		||||
      /* 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( "<xsl:call-template name="i18n-record-saved"/>");
 | 
			
		||||
| 
						 | 
				
			
			@ -664,6 +669,7 @@
 | 
			
		|||
 | 
			
		||||
      if ( record != null)
 | 
			
		||||
      {
 | 
			
		||||
      record.BeforeDeleteHook( hibernator);
 | 
			
		||||
      hibernator.Delete( record);
 | 
			
		||||
      hibernator.Flush();
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue