Spent a lot of time trying to get Andrew's (very clever) automatic type resolution to widgets working, but without good success, so I've backed out a lot of code. It may still be the right approach, but will take much more work to get working.
This commit is contained in:
parent
7b1f458583
commit
dff905227d
|
@ -9,8 +9,8 @@
|
||||||
Transform ADL into (partial) controller classes
|
Transform ADL into (partial) controller classes
|
||||||
|
|
||||||
$Author: sb $
|
$Author: sb $
|
||||||
$Revision: 1.25 $
|
$Revision: 1.26 $
|
||||||
$Date: 2008-05-13 10:36:46 $
|
$Date: 2008-05-15 16:29:24 $
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
|
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
|
||||||
|
@ -71,7 +71,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.25 $', 10)"/>
|
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.26 $', 10)"/>
|
||||||
//
|
//
|
||||||
// This file is automatically generated; DO NOT EDIT IT.
|
// This file is automatically generated; DO NOT EDIT IT.
|
||||||
//
|
//
|
||||||
|
@ -128,7 +128,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
//
|
//
|
||||||
// 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.25 $', 10)"/>
|
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.26 $', 10)"/>
|
||||||
//
|
//
|
||||||
// This file is automatically generated; DO NOT EDIT IT.
|
// This file is automatically generated; DO NOT EDIT IT.
|
||||||
//
|
//
|
||||||
|
@ -148,6 +148,7 @@ using Castle.MonoRail.Framework.Helpers;
|
||||||
using Cygnet.Exceptions;
|
using Cygnet.Exceptions;
|
||||||
using Cygnet.Web.Helpers;
|
using Cygnet.Web.Helpers;
|
||||||
using Cygnet.Web.Controllers;
|
using Cygnet.Web.Controllers;
|
||||||
|
using Cygnet.Web.SmartControls;
|
||||||
using NHibernate;
|
using NHibernate;
|
||||||
using NHibernate.Expression;
|
using NHibernate.Expression;
|
||||||
using Castle.MonoRail.Framework;
|
using Castle.MonoRail.Framework;
|
||||||
|
@ -164,13 +165,38 @@ namespace <xsl:value-of select="$controllerns"/> {
|
||||||
///
|
///
|
||||||
/// DO NOT EDIT THIS FILE!
|
/// DO NOT EDIT THIS FILE!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ Layout("<xsl:value-of select="$layout-name"/>"),
|
[
|
||||||
Rescue("<xsl:value-of select="$rescue-name"/>"),
|
Layout("<xsl:value-of select="$layout-name"/>"),
|
||||||
ControllerDetails("<xsl:value-of select="@name"/>",
|
Rescue("<xsl:value-of select="$rescue-name"/>"),
|
||||||
Area = "<xsl:value-of select="$area-name"/>")]
|
ControllerDetails("<xsl:value-of select="@name"/>", Area = "<xsl:value-of select="$area-name"/>"),
|
||||||
public partial class <xsl:value-of select="@name"/>Controller : <xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/> {
|
Helper(typeof(<xsl:value-of select="concat( @name, 'FieldHelper')"/>), "<xsl:value-of select="concat( @name, 'FieldHelper')"/>")
|
||||||
|
]
|
||||||
|
public partial class <xsl:value-of select="concat( @name, 'Controller')"/>Controller : <xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/> {
|
||||||
|
|
||||||
<xsl:if test="adl:form">
|
/* The SmartFormHelper stuff in generated controller classes does not yet work. There is some
|
||||||
|
* hope that in future it will offer definite benefits and in the mean time it is doing no harm.
|
||||||
|
* However if you are looking for bugs look elsewhere - this is not currently used */
|
||||||
|
protected class <xsl:value-of select="concat( @name, 'FieldHelper')"/> : SmartFormHelper {
|
||||||
|
public <xsl:value-of select="concat( @name, 'FieldHelper')"/>() {
|
||||||
|
<xsl:for-each select="descendant::adl:property[@type='entity']">
|
||||||
|
<xsl:variable name="entityname" select="@entity"/>
|
||||||
|
<xsl:variable name="entity" select="//adl:entity[@name=$entityname]"/>
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$entity/@foreign='true'">
|
||||||
|
/* Entity <xsl:value-of select="$entityname"/> is foreign..? */
|
||||||
|
<xsl:variable name="foreignkey" select="$entity/adl:key/adl:property[position()=1]/@name"/>
|
||||||
|
Register<<xsl:value-of select="concat( $entityns, '.', $entityname)"/>>( "",
|
||||||
|
new TypeMenuControl<<xsl:value-of select="concat( $entityns, '.', $entityname)"/>>( "<xsl:value-of select="$foreignkey"/>","<xsl:value-of select="$foreignkey"/>"));
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
Register<<xsl:value-of select="concat( $entityns, '.', $entityname)"/>>( "", EntityMenuControl<<xsl:value-of select="concat( $entityns, '.', $entityname)"/>>.Instance);
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:for-each>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<xsl:if test="adl:form">
|
||||||
<!-- unless there's at least one form, we won't generate a 'store' method -->
|
<!-- unless there's at least one form, we won't generate a 'store' method -->
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Store the record represented by the parameters passed in an HTTP service
|
/// Store the record represented by the parameters passed in an HTTP service
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
Transform ADL into velocity view templates
|
Transform ADL into velocity view templates
|
||||||
|
|
||||||
$Author: sb $
|
$Author: sb $
|
||||||
$Revision: 1.16 $
|
$Revision: 1.17 $
|
||||||
$Date: 2008-05-09 16:12:12 $
|
$Date: 2008-05-15 16:30:25 $
|
||||||
-->
|
-->
|
||||||
<!-- 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! -->
|
||||||
|
@ -104,7 +104,7 @@
|
||||||
Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
|
Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
|
||||||
generated from ADL.
|
generated from ADL.
|
||||||
|
|
||||||
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.16 $', 10)"/>
|
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.17 $', 10)"/>
|
||||||
</xsl:comment>
|
</xsl:comment>
|
||||||
<xsl:call-template name="maybe-delete">
|
<xsl:call-template name="maybe-delete">
|
||||||
<xsl:with-param name="entity" select="."/>
|
<xsl:with-param name="entity" select="."/>
|
||||||
|
@ -141,7 +141,7 @@
|
||||||
Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
|
Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
|
||||||
generated from ADL.
|
generated from ADL.
|
||||||
|
|
||||||
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.16 $', 10)"/>
|
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.17 $', 10)"/>
|
||||||
</xsl:comment>
|
</xsl:comment>
|
||||||
<xsl:call-template name="install-scripts"/>
|
<xsl:call-template name="install-scripts"/>
|
||||||
</head>
|
</head>
|
||||||
|
@ -227,7 +227,7 @@
|
||||||
Auto generated Velocity <xsl:value-of select="@name"/> form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
|
Auto generated Velocity <xsl:value-of select="@name"/> form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
|
||||||
generated from ADL.
|
generated from ADL.
|
||||||
|
|
||||||
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.16 $', 10)"/>
|
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.17 $', 10)"/>
|
||||||
</xsl:comment>
|
</xsl:comment>
|
||||||
#capturefor( title)
|
#capturefor( title)
|
||||||
#if ( $instance)
|
#if ( $instance)
|
||||||
|
@ -351,7 +351,7 @@
|
||||||
Auto generated Velocity form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
|
Auto generated Velocity form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
|
||||||
generated from ADL.
|
generated from ADL.
|
||||||
|
|
||||||
Generated using adl2views.xsl <xsl:value-of select="substring( '$Revision: 1.16 $', 10)"/>
|
Generated using adl2views.xsl <xsl:value-of select="substring( '$Revision: 1.17 $', 10)"/>
|
||||||
</xsl:comment>
|
</xsl:comment>
|
||||||
<xsl:call-template name="install-scripts"/>
|
<xsl:call-template name="install-scripts"/>
|
||||||
<script type='text/javascript' language='JavaScript1.2'>
|
<script type='text/javascript' language='JavaScript1.2'>
|
||||||
|
@ -482,7 +482,9 @@
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<!-- create a hidden widget for the natural primary key -->
|
<!-- create a hidden widget for the natural primary key -->
|
||||||
|
#if ( $instance)
|
||||||
${FormHelper.HiddenField( "instance.<xsl:value-of select="$keyname"/>")}
|
${FormHelper.HiddenField( "instance.<xsl:value-of select="$keyname"/>")}
|
||||||
|
#end
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
|
@ -994,35 +996,45 @@
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="@type='entity'">
|
<xsl:when test="@type='entity'">
|
||||||
<xsl:value-of select="concat('$instance.', @name, '.UserIdentifier')"/>
|
<xsl:value-of select="concat('$instance.', @name, '.UserIdentifier')"/>
|
||||||
${FormHelper.HiddenField( <xsl:value-of select="concat('$instance.', @name, '.KeyString')"/>)}
|
#if ( $instance)
|
||||||
|
${FormHelper.HiddenField( "<xsl:value-of select="concat('instance.', @name, '.KeyString')"/>")}
|
||||||
|
#end
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<!-- TODO: if @type='list' or 'link', should generate Velocity to generate ul list
|
<!-- TODO: if @type='list' or 'link', should generate Velocity to generate ul list
|
||||||
of UserIdentifiers
|
of UserIdentifiers
|
||||||
-->
|
-->
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:value-of select="concat('$instance.', @name)"/>
|
<xsl:value-of select="concat('$instance.', @name)"/>
|
||||||
${FormHelper.HiddenField( <xsl:value-of select="concat('$instance.', @name)"/>)}
|
#if ( $instance)
|
||||||
|
${FormHelper.HiddenField( "<xsl:value-of select="concat('instance.', @name)"/>")}
|
||||||
|
#end
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="$permission='insert' or $permission='noedit'">
|
<xsl:when test="$permission='insert' or $permission='noedit'">
|
||||||
|
#if ( $instance)
|
||||||
#if ($instance.<xsl:value-of select="@name"/>)
|
#if ($instance.<xsl:value-of select="@name"/>)
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="@type='entity'">
|
<xsl:when test="@type='entity'">
|
||||||
<xsl:value-of select="concat('$instance.', @name, '.UserIdentifier')"/>
|
<xsl:value-of select="concat('$instance.', @name, '.UserIdentifier')"/>
|
||||||
${FormHelper.HiddenField( <xsl:value-of select="concat('$instance.', @name, '.KeyString')"/>)}
|
${FormHelper.HiddenField( "<xsl:value-of select="concat('instance.', @name, '.KeyString')"/>")}
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:value-of select="concat('$instance.', @name)"/>
|
<xsl:value-of select="concat('$instance.', @name)"/>
|
||||||
${FormHelper.HiddenField( <xsl:value-of select="concat('$instance.', @name)"/>)}
|
${FormHelper.HiddenField( "<xsl:value-of select="concat('instance.', @name)"/>")}
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
#else
|
#else
|
||||||
<xsl:call-template name="widget">
|
<xsl:call-template name="widget">
|
||||||
<xsl:with-param name="property" select="."/>
|
<xsl:with-param name="property" select="."/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
#end
|
#end
|
||||||
</xsl:when>
|
#else
|
||||||
|
<xsl:call-template name="widget">
|
||||||
|
<xsl:with-param name="property" select="."/>
|
||||||
|
</xsl:call-template>
|
||||||
|
#end
|
||||||
|
</xsl:when>
|
||||||
<!-- TODO: if $permission='insert', then you should get an editable widget if there
|
<!-- TODO: if $permission='insert', then you should get an editable widget if there
|
||||||
is no current value, else a 'not authorised' message -->
|
is no current value, else a 'not authorised' message -->
|
||||||
<!-- TODO: if $permission='noedit', then you should get an editable widget if there
|
<!-- TODO: if $permission='noedit', then you should get an editable widget if there
|
||||||
|
@ -1347,7 +1359,7 @@
|
||||||
Auto generated Velocity list for <xsl:value-of select="ancestor::adl:entity/@name"/>,
|
Auto generated Velocity list for <xsl:value-of select="ancestor::adl:entity/@name"/>,
|
||||||
generated from ADL.
|
generated from ADL.
|
||||||
|
|
||||||
Generated using adl2listview.xsl <xsl:value-of select="substring( '$Revision: 1.16 $', 10)"/>
|
Generated using adl2listview.xsl <xsl:value-of select="substring( '$Revision: 1.17 $', 10)"/>
|
||||||
</xsl:comment>
|
</xsl:comment>
|
||||||
<xsl:call-template name="install-scripts"/>
|
<xsl:call-template name="install-scripts"/>
|
||||||
</head>
|
</head>
|
||||||
|
|
Loading…
Reference in a new issue