bug 2935 : This proved to be a more complicated problem than it might have. Exceptions thrown during deletion were not caught by the user interface, so the user got a fairly ugly error message. Fixed.

status 2935 : resolved FIXED
This commit is contained in:
sb 2009-05-12 15:43:18 +00:00
parent 9fac74f803
commit b87e01bd64
2 changed files with 57 additions and 21 deletions

View file

@ -9,8 +9,8 @@
Transform ADL into (partial) controller classes Transform ADL into (partial) controller classes
$Author: sb $ $Author: sb $
$Revision: 1.42 $ $Revision: 1.43 $
$Date: 2009-05-12 14:29:12 $ $Date: 2009-05-12 15:43:18 $
--> -->
<!-- WARNING WARNING WARNING: Do NOT reformat this file! <!-- WARNING WARNING WARNING: Do NOT reformat this file!
@ -72,7 +72,7 @@
// //
// Automatically generated abstract super class for controllers for the // Automatically generated abstract super class for controllers for the
// <xsl:value-of select="/adl:application/@name"/> application; generated using // <xsl:value-of select="/adl:application/@name"/> application; generated using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.42 $', 10)"/> // adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.43 $', 10)"/>
// //
// <xsl:value-of select="/adl:application/@revision"/> // <xsl:value-of select="/adl:application/@revision"/>
// //
@ -182,7 +182,7 @@
// //
// Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s // Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s
// Automatically generated from application description using // Automatically generated from application description using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.42 $', 10)"/> // adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.43 $', 10)"/>
// //
// This file is automatically generated; DO NOT EDIT IT. // This file is automatically generated; DO NOT EDIT IT.
// //
@ -684,27 +684,33 @@
/// &lt;summary&gt; /// &lt;summary&gt;
/// Actually delete the selected record /// Actually delete the selected record
/// &lt;/summary&gt; /// &lt;/summary&gt;
[AccessibleThrough(Verb.Post)] [AccessibleThrough(Verb.Post)]
public void Delete() public void Delete()
{ {
AssertUserCanDelete(); AssertUserCanDelete();
ISession hibernator = GetDBSession(); ISession hibernator = GetDBSession();
<xsl:value-of select="concat($entityns, '.', @name)"/> record = null;
if ( "true".Equals( Params["reallydelete"])) if ( "true".Equals( Params["reallydelete"]))
{ {
<xsl:value-of select="concat($entityns, '.', @name)"/> record = FetchRecord( hibernator); record = FetchRecord( hibernator);
if ( record != null) if ( record != null)
{ {
try {
record.BeforeDeleteHook( hibernator); record.BeforeDeleteHook( hibernator);
hibernator.Delete( record); hibernator.Delete( record);
hibernator.Flush(); hibernator.Flush();
} catch ( DomainKnowledgeViolationException dkve) {
AddError( dkve);
}
} }
else else
{ {
throw new ApplicationException( "No such record?"); throw new ApplicationException( "No such record?");
} }
} }
if ( HasNoErrors()) {
<xsl:choose> <xsl:choose>
<xsl:when test="adl:list"> <xsl:when test="adl:list">
Redirect( "<xsl:value-of select="concat(adl:list[position()=1]/@name, '.rails')"/>"); Redirect( "<xsl:value-of select="concat(adl:list[position()=1]/@name, '.rails')"/>");
@ -713,8 +719,12 @@
Redirect( FormsAuthentication.DefaultUrl); Redirect( FormsAuthentication.DefaultUrl);
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
} } else {
</xsl:if> PropertyBag[ "instance"] = record;
RenderViewWithFailover( "maybedelete.vm", "maybedelete.auto.vm");
}
}
</xsl:if>
<xsl:apply-templates select="adl:form"/> <xsl:apply-templates select="adl:form"/>
<xsl:if test="adl:list"> <xsl:if test="adl:list">

View file

@ -15,8 +15,8 @@
Transform ADL into velocity view templates Transform ADL into velocity view templates
$Author: sb $ $Author: sb $
$Revision: 1.59 $ $Revision: 1.60 $
$Date: 2009-05-12 14:29:12 $ $Date: 2009-05-12 15:43:18 $
--> -->
<!-- WARNING WARNING WARNING: Do NOT reformat this file! <!-- WARNING WARNING WARNING: Do NOT reformat this file!
Whitespace (or lack of it) is significant! --> Whitespace (or lack of it) is significant! -->
@ -129,10 +129,10 @@
</xsl:comment> </xsl:comment>
<xsl:call-template name="head"/> <xsl:call-template name="head"/>
#end #end
<xsl:call-template name="maybe-delete"> <xsl:call-template name="maybe-delete">
<xsl:with-param name="entity" select="."/> <xsl:with-param name="entity" select="."/>
</xsl:call-template> </xsl:call-template>
</xsl:template> </xsl:template>
<!-- generate views for an entity, assuming an empty layout <!-- generate views for an entity, assuming an empty layout
(i.e. I'm responsible for html, head and body tags) --> (i.e. I'm responsible for html, head and body tags) -->
@ -181,6 +181,32 @@
<xsl:template name="maybe-delete"> <xsl:template name="maybe-delete">
<xsl:param name="entity"/> <xsl:param name="entity"/>
<div class="content"> <div class="content">
<xsl:if test="$show-errors = 'true'">
#if ( $errors)
#if ( $errors.Count != 0)
<ul class="errors">
#foreach($e in $errors)
#if($e.Message)
<li>$t.Error($e)</li>
#else
<li>$t.Enc($e)</li>
#end
#end
</ul>
#end
#end
</xsl:if>
<xsl:if test="$show-messages = 'true'">
#if( $messages)
#if ( $messages.Count != 0)
<ul class="information">
#foreach ( $message in $messages)
<li>$message</li>
#end
</ul>
#end
#end
</xsl:if>
<form action="delete.rails" method="post"> <form action="delete.rails" method="post">
<xsl:for-each select="$entity/adl:key/adl:property"> <xsl:for-each select="$entity/adl:key/adl:property">
<xsl:choose> <xsl:choose>
@ -1822,7 +1848,7 @@
Auto generated Velocity macro for <xsl:value-of select="@name"/>, Auto generated Velocity macro for <xsl:value-of select="@name"/>,
generated from ADL. generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.59 $', 10)"/> Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.60 $', 10)"/>
Generation parameters were: Generation parameters were:
area-name: <xsl:value-of select="$area-name"/> area-name: <xsl:value-of select="$area-name"/>
default-url: <xsl:value-of select="$default-url"/> default-url: <xsl:value-of select="$default-url"/>