Almost completely working with Andrew's new SmartForm stuff.

This commit is contained in:
sb 2008-05-16 15:26:20 +00:00
parent 7673552477
commit 41f45eb3cd
3 changed files with 606 additions and 824 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.27 $ $Revision: 1.28 $
$Date: 2008-05-16 11:12:48 $ $Date: 2008-05-16 15:26:20 $
--> -->
<!-- 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.27 $', 10)"/> // adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.28 $', 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.27 $', 10)"/> // adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.28 $', 10)"/>
// //
// This file is automatically generated; DO NOT EDIT IT. // This file is automatically generated; DO NOT EDIT IT.
// //
@ -704,6 +704,10 @@ namespace <xsl:value-of select="$controllerns"/> {
{ {
AssertUserCanRead(); AssertUserCanRead();
/* we don't actually instantiate this local variable; it exists to that
* TypedPropertyBag can do introspection to infer property types */
<xsl:value-of select="concat($entityns, '.', ancestor::adl:entity/@name)"/> record = null;
ISession hibernator = ISession hibernator =
NHibernateHelper.GetCurrentSession( <xsl:if test="$authentication-layer = 'Database'">Session[ NHibernateHelper.USERTOKEN], NHibernateHelper.GetCurrentSession( <xsl:if test="$authentication-layer = 'Database'">Session[ NHibernateHelper.USERTOKEN],
Session[NHibernateHelper.PASSTOKEN]</xsl:if>); Session[NHibernateHelper.PASSTOKEN]</xsl:if>);
@ -715,7 +719,7 @@ namespace <xsl:value-of select="$controllerns"/> {
<xsl:call-template name="formmenus"> <xsl:call-template name="formmenus">
<xsl:with-param name="form" select="."/> <xsl:with-param name="form" select="."/>
</xsl:call-template> </xsl:call-template>
lastentry = "trailing-comma-avoidance" /* yes, it's a hack */ instance = record
}; };
RenderViewWithFailover("<xsl:value-of select="concat( @name, '.vm')"/>", RenderViewWithFailover("<xsl:value-of select="concat( @name, '.vm')"/>",
@ -906,8 +910,8 @@ namespace <xsl:value-of select="$controllerns"/> {
<!-- produce all menus for a given form: harder, but more efficient --> <!-- produce all menus for a given form: harder, but more efficient -->
<xsl:template name="formmenus"> <xsl:template name="formmenus">
<!-- an entity assumed to be of type adl:form -->
<xsl:param name="form"/> <xsl:param name="form"/>
/* set up menus for the form, if required */
<xsl:choose> <xsl:choose>
<xsl:when test="$form/@properties = 'all'"> <xsl:when test="$form/@properties = 'all'">
<xsl:call-template name="entitymenus"> <xsl:call-template name="entitymenus">

File diff suppressed because it is too large Load diff

View file

@ -10,8 +10,8 @@
one place for ease of maintenance one place for ease of maintenance
$Author: sb $ $Author: sb $
$Revision: 1.4 $ $Revision: 1.5 $
$Date: 2008-02-27 17:38:41 $ $Date: 2008-05-16 15:26:20 $
--> -->
<xsl:stylesheet version="1.0" <xsl:stylesheet version="1.0"
@ -21,38 +21,55 @@
exclude-result-prefixes="adl"> exclude-result-prefixes="adl">
<!-- return the base ADL type of the property which is passed as a parameter --> <!-- return the base ADL type of the property which is passed as a parameter -->
<xsl:template name="base-type"> <xsl:template name="base-type">
<xsl:param name="property"/> <xsl:param name="property"/>
<xsl:choose> <xsl:choose>
<xsl:when test="$property/@type='defined'"> <xsl:when test="$property/@type='defined'">
<xsl:variable name="definition"> <xsl:variable name="definition">
<xsl:value-of select="$property/@typedef"/> <xsl:value-of select="$property/@typedef"/>
</xsl:variable> </xsl:variable>
<xsl:value-of select="/adl:application/adl:typedef[@name=$definition]/@type"/> <xsl:value-of select="/adl:application/adl:typedef[@name=$definition]/@type"/>
</xsl:when> </xsl:when>
<xsl:when test="$property/@type='serial'">integer</xsl:when> <xsl:when test="$property/@type='serial'">integer</xsl:when>
<xsl:when test="$property/@type='message'">integer</xsl:when> <xsl:when test="$property/@type='message'">integer</xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="$property/@type"/> <xsl:value-of select="$property/@type"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:template> </xsl:template>
<!-- return the size of the type of the property which is passed as a parameter --> <!-- return the size of the type of the property which is passed as a parameter -->
<xsl:template name="base-size"> <xsl:template name="base-size">
<xsl:param name="property"/> <xsl:param name="property"/>
<xsl:choose> <xsl:variable name="base-type">
<xsl:when test="$property/@type='defined'"> <xsl:call-template name="base-type">
<xsl:variable name="definition"> <xsl:with-param name="property" select="$property"/>
<xsl:value-of select="$property/@typedef"/> </xsl:call-template>
</xsl:variable> </xsl:variable>
<xsl:value-of select="/adl:application/adl:typedef[@name=$definition]/@size"/> <xsl:choose>
</xsl:when> <xsl:when test="$property/@type='defined'">
<xsl:otherwise> <xsl:variable name="definition">
<xsl:value-of select="$property/@size"/> <xsl:value-of select="$property/@typedef"/>
</xsl:otherwise> </xsl:variable>
</xsl:choose> <xsl:value-of select="/adl:application/adl:typedef[@name=$definition]/@size"/>
</xsl:template> </xsl:when>
<!-- type='text' should really be unlimited, but in the real world it isn't.
Furthermore, setting null values may currently break the smart form components
parser -->
<xsl:when test="$base-type='text'">4294967296</xsl:when>
<xsl:when test="$base-type='integer'">8</xsl:when>
<xsl:when test="$base-type='real'">8</xsl:when>
<xsl:when test="$base-type='money'">10</xsl:when>
<xsl:when test="$base-type='date'">10</xsl:when>
<xsl:when test="$base-type='time'">8</xsl:when>
<xsl:when test="$property/@size &gt; 0">
<xsl:value-of select="$property/@size"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$base-type"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>