bug 1954 - was assuming keys would be passed in, and of course they aren't on creation.
This commit is contained in:
parent
090268cdbd
commit
2e9aa81fe5
|
@ -9,8 +9,8 @@
|
|||
Transform ADL into (partial) controller classes
|
||||
|
||||
$Author: sb $
|
||||
$Revision: 1.12 $
|
||||
$Date: 2008-06-09 15:52:07 $
|
||||
$Revision: 1.13 $
|
||||
$Date: 2008-06-10 08:51:16 $
|
||||
-->
|
||||
|
||||
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
|
||||
|
@ -67,7 +67,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.12 $', 10)"/>
|
||||
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.13 $', 10)"/>
|
||||
//
|
||||
// This file is automatically generated; DO NOT EDIT IT.
|
||||
//
|
||||
|
@ -133,7 +133,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.12 $', 10)"/>
|
||||
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.13 $', 10)"/>
|
||||
//
|
||||
// This file is automatically generated; DO NOT EDIT IT.
|
||||
//
|
||||
|
@ -290,6 +290,7 @@
|
|||
AssertUserCanCreate();
|
||||
|
||||
try {
|
||||
if ( AllKeys()) {
|
||||
record = new <xsl:value-of select="concat($entityns, '.', @name)"/>(<xsl:for-each select="adl:key/adl:property">
|
||||
<xsl:variable name="basetype">
|
||||
<xsl:call-template name="base-type">
|
||||
|
@ -328,6 +329,11 @@
|
|||
</xsl:choose>
|
||||
</xsl:for-each>);
|
||||
}
|
||||
else
|
||||
{
|
||||
record = new <xsl:value-of select="concat($entityns, '.', @name)"/>();
|
||||
}
|
||||
}
|
||||
catch ( FormatException) {
|
||||
/* failed to parse a number - not wholly unexpected, since it's most likely
|
||||
* that an empty string was passed in */
|
||||
|
@ -673,27 +679,33 @@
|
|||
}
|
||||
</xsl:if>
|
||||
|
||||
/// <summary>
|
||||
/// Check whether values for all my keys are available in the form fields
|
||||
/// </summary>
|
||||
protected bool AllKeys() {
|
||||
/* whether we have valid values for all the key fields */
|
||||
bool result = true;
|
||||
|
||||
<xsl:for-each select="adl:key/adl:property">
|
||||
if ( String.IsNullOrEmpty( Form["<xsl:value-of select="concat( 'instance.', @name)"/>"])) {
|
||||
result = false;
|
||||
} else if ( "<xsl:value-of select="concat('$instance.', @name)"/>".Equals( Form["<xsl:value-of select="concat( 'instance.', @name)"/>"])) {
|
||||
/* nasty artefact of NVelocity forms - default 'null value' is dollar followed by fieldname */
|
||||
result = false;
|
||||
}
|
||||
</xsl:for-each>
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetch the record represented by the values in the current Form
|
||||
/// </summary>
|
||||
protected <xsl:value-of select="concat($entityns, '.', @name)"/> FetchRecord(ISession hibernator) {
|
||||
/* the instance (record) of type <xsl:value-of select="@name"/> we're dealing with */
|
||||
<xsl:value-of select="concat($entityns, '.', @name)"/> record = null;
|
||||
/* whether we have valid values for all the key fields */
|
||||
bool allkeys = true;
|
||||
|
||||
/* check whether values for all key slots have been passed in; if so, we're probably dealing with an
|
||||
* existing record */
|
||||
<xsl:for-each select="adl:key/adl:property">
|
||||
if ( String.IsNullOrEmpty( Form["<xsl:value-of select="concat( 'instance.', @name)"/>"])) {
|
||||
allkeys = false;
|
||||
} else if ( "<xsl:value-of select="concat('$instance.', @name)"/>".Equals( Form["<xsl:value-of select="concat( 'instance.', @name)"/>"])) {
|
||||
/* nasty artefact of NVelocity forms - default 'null value' is dollar followed by fieldname */
|
||||
allkeys = false;
|
||||
}
|
||||
</xsl:for-each>
|
||||
|
||||
if ( allkeys){
|
||||
if ( AllKeys()){
|
||||
/* it's (probably) existing, retrieve it */
|
||||
record = hibernator.CreateCriteria(typeof(<xsl:value-of select="concat( $entityns, '.', @name)"/>))
|
||||
<xsl:for-each select="adl:key/adl:property">
|
||||
|
|
Loading…
Reference in a new issue