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">

View file

@ -12,8 +12,8 @@
Transform ADL into velocity view templates Transform ADL into velocity view templates
$Author: sb $ $Author: sb $
$Revision: 1.17 $ $Revision: 1.18 $
$Date: 2008-05-15 16:30:25 $ $Date: 2008-05-16 15:26:20 $
--> -->
<!-- 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! -->
@ -21,6 +21,9 @@
<!-- <!--
TODO: this transform BADLY needs to be refactored! It is /crap/! TODO: this transform BADLY needs to be refactored! It is /crap/!
--> -->
<xsl:include href="base-type-include.xslt"/>
<xsl:output method="xml" indent="yes" encoding="UTF-8" omit-xml-declaration="yes"/> <xsl:output method="xml" indent="yes" encoding="UTF-8" omit-xml-declaration="yes"/>
<!-- The locale for which these views are generated <!-- The locale for which these views are generated
@ -36,6 +39,8 @@
<!-- whether or not to layout messages - they may be in the default layout --> <!-- whether or not to layout messages - they may be in the default layout -->
<xsl:param name="show-messages" select="'false'"/> <xsl:param name="show-messages" select="'false'"/>
<!-- the maximum width, in characters, we're prepared to allocate to widgets -->
<xsl:param name="max-widget-width" select="40"/>
<!-- the current state of play is that we can only generate views with permissions for one group. <!-- the current state of play is that we can only generate views with permissions for one group.
TODO: this isn't how it's supposed to be. It's supposed to be that at service time the system TODO: this isn't how it's supposed to be. It's supposed to be that at service time the system
@ -63,6 +68,8 @@
<xsl:apply-templates select="adl:entity"/> <xsl:apply-templates select="adl:entity"/>
<!-- make sure extraneous junk doesn't get into the last file generated, <!-- make sure extraneous junk doesn't get into the last file generated,
by putting it into a separate file --> by putting it into a separate file -->
<xsl:text>
</xsl:text>
<xsl:comment> [ cut here: next file 'tail.txt' ] </xsl:comment> <xsl:comment> [ cut here: next file 'tail.txt' ] </xsl:comment>
</output> </output>
</xsl:template> </xsl:template>
@ -104,7 +111,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.17 $', 10)"/> Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.18 $', 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="."/>
@ -127,9 +134,7 @@
<xsl:apply-templates select="adl:list" mode="empty-layout"/> <xsl:apply-templates select="adl:list" mode="empty-layout"/>
<xsl:text> <xsl:text>
</xsl:text> </xsl:text>
<xsl:comment> <xsl:comment>[ cut here: next file '<xsl:value-of select="concat( @name, '/maybedelete.auto.vm')"/>' ]</xsl:comment>
[ cut here: next file '<xsl:value-of select="concat( @name, '/maybedelete.auto.vm')"/>' ]
</xsl:comment>
<xsl:text> <xsl:text>
</xsl:text> </xsl:text>
<html> <html>
@ -141,7 +146,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.17 $', 10)"/> Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.18 $', 10)"/>
</xsl:comment> </xsl:comment>
<xsl:call-template name="install-scripts"/> <xsl:call-template name="install-scripts"/>
</head> </head>
@ -227,7 +232,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.17 $', 10)"/> Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.18 $', 10)"/>
</xsl:comment> </xsl:comment>
#capturefor( title) #capturefor( title)
#if ( $instance) #if ( $instance)
@ -351,7 +356,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.17 $', 10)"/> Generated using adl2views.xsl <xsl:value-of select="substring( '$Revision: 1.18 $', 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'>
@ -772,7 +777,9 @@
</xsl:choose> </xsl:choose>
</xsl:variable> </xsl:variable>
<tr> <tr>
<xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute> <xsl:attribute name="class">
<xsl:value-of select="$class"/>
</xsl:attribute>
<td colspan="2"> <td colspan="2">
<xsl:attribute name="class"> <xsl:attribute name="class">
<xsl:value-of select="$class"/> <xsl:value-of select="$class"/>
@ -814,7 +821,9 @@
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<!-- it's presumably intended to be a computed field --> <!-- it's presumably intended to be a computed field -->
<xsl:comment>Computed field (<xsl:value-of select="$propname"/>)? TODO: Not yet implememented</xsl:comment> <xsl:comment>
Computed field (<xsl:value-of select="$propname"/>)? TODO: Not yet implememented
</xsl:comment>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:template> </xsl:template>
@ -913,64 +922,16 @@
</tr> </tr>
</xsl:template> </xsl:template>
<xsl:template match="adl:property[@type='text']">
<!-- note! this template is only intended to match properties in the context of a form:
it may be we need to add a mode to indicate this! -->
<!-- text box widgets, like shuffle widgets, extend over both columns -->
<!-- TODO: Permissions! -->
<xsl:param name="oddness" select="odd"/>
<xsl:variable name="if-missing">
<xsl:choose>
<xsl:when test="if-missing[@locale = $locale]">
<xsl:value-of select="if-missing[@locale = $locale]"/>
</xsl:when>
<xsl:when test="required='true'">You must provide a value for <xsl:value-of select="@name"/></xsl:when>
<xsl:otherwise>Enter a value for <xsl:value-of select="@name"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<tr>
<xsl:attribute name="class">
<xsl:value-of select="$oddness"/>
</xsl:attribute>
<td class="label" rowspan="2">
${FormHelper.LabelFor( "instance.<xsl:value-of select="@name"/>", "<xsl:call-template name="showprompt">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="fallback" select="@name"/>
</xsl:call-template>")}
</td>
<td class="widget" colspan="2">
${FormHelper.TextArea( "instance.<xsl:value-of select="@name"/>", "%{rows='8', cols='60', title='<xsl:value-of select="$if-missing"/>'}")}
</td>
</tr>
<tr>
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="position() mod 2 = 0">even</xsl:when>
<xsl:otherwise>odd</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<td class="help" colspan="2">
<xsl:apply-templates select="adl:help[@locale = $locale]"/>
</td>
</tr>
</xsl:template>
<xsl:template match="adl:property"> <xsl:template match="adl:property">
<xsl:param name="oddness" select="odd"/> <xsl:param name="oddness" select="odd"/>
<!-- note! this template is only intended to match properties in the context of a form: <!-- note! this template is only intended to match properties in the context of a form:
it may be we need to add a mode to indicate this! --> it may be we need to add a mode to indicate this! -->
<!-- TODO: This really needs to be refactored -->
<!-- TODO: we really need to be able to handle different permissions for different <!-- TODO: we really need to be able to handle different permissions for different
groups. If the current user is not a member of a group which has read access to groups. If the current user is not a member of a group which has read access to
this widget, the widget shouldn't even appear (unless they have write but not read?); this widget, the widget shouldn't even appear (unless they have write but not read?);
if they are not a member of a group which has write access, the widget should be if they are not a member of a group which has write access, the widget should be
disabled. I don't have time to implement this now as it is not trivial, but it is disabled. I don't have time to implement this now as it is not trivial, but it is
important! --> important! -->
<!-- TODO: this is a one-database-role permission model, because that's all SRU needs.
Different permissions for different database groups is much more complex! Also, this
handles permissions on only properties and entities, not on forms. Perhaps we need a
Helper class? -->
<xsl:variable name="permission"> <xsl:variable name="permission">
<xsl:call-template name="property-permission"> <xsl:call-template name="property-permission">
<xsl:with-param name="property" select="."/> <xsl:with-param name="property" select="."/>
@ -988,63 +949,99 @@
</xsl:call-template>")} </xsl:call-template>")}
</td> </td>
<td class="widget"> <td class="widget">
<xsl:variable name="render-mode">
<xsl:choose> <xsl:choose>
<xsl:when test="$permission='none'"> <xsl:when test="$permission='all'">edit</xsl:when>
[You are not authorised to see this data] <xsl:when test="$permission='edit'">edit</xsl:when>
<xsl:when test="$permission='noedit'">$maybe-edit</xsl:when>
<xsl:when test="$permission='insert'">$maybe-edit</xsl:when>
<xsl:when test="$permission='read'">noneditable</xsl:when>
<xsl:otherwise>none</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="if-missing">
<xsl:choose>
<xsl:when test="adl:if-missing[@locale = $locale]">
<xsl:value-of select="adl:if-missing[@locale = $locale]"/>
</xsl:when>
<xsl:when test="@required='true'">
You must provide a value for <xsl:value-of select="@name"/>
</xsl:when>
<xsl:when test="@type='defined'">
The value for <xsl:value-of select="@name"/> must be <xsl:value-of select="@definition"/>
</xsl:when> </xsl:when>
<xsl:when test="$permission='read'">
<xsl:choose>
<xsl:when test="@type='entity'"> <xsl:when test="@type='entity'">
<xsl:value-of select="concat('$instance.', @name, '.UserIdentifier')"/> The value for <xsl:value-of select="@name"/> must be an instance of <xsl:value-of select="@entity"/>
#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
of UserIdentifiers
-->
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="concat('$instance.', @name)"/> The value for <xsl:value-of select="@name"/> must be <xsl:value-of select="@type"/>
#if ( $instance)
${FormHelper.HiddenField( "<xsl:value-of select="concat('instance.', @name)"/>")}
#end
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:when> </xsl:variable>
<xsl:when test="$permission='insert' or $permission='noedit'"> <xsl:variable name="definition" select="@typedef"/>
#if ( $instance) <xsl:variable name="definedtype" select="//adl:typedef[@name=$definition]/@type"/>
#if ($instance.<xsl:value-of select="@name"/>) <xsl:variable name="base-type">
<xsl:call-template name="base-type">
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="cssclass">
<xsl:if test="@required='true'">required </xsl:if>
<xsl:choose> <xsl:choose>
<xsl:when test="@type='entity'"> <xsl:when test="@type='defined'">
<xsl:value-of select="concat('$instance.', @name, '.UserIdentifier')"/> <xsl:choose>
${FormHelper.HiddenField( "<xsl:value-of select="concat('instance.', @name, '.KeyString')"/>")} <xsl:when test="//adl:typedef[@name=$definition]/@pattern">
<xsl:value-of select="concat( 'validate-custom-', $definition)"/>
</xsl:when>
<xsl:when test="//adl:typedef[@name=$definition]/@minimum">
<xsl:value-of select="concat( 'validate-custom-', $definition)"/>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="$base-type='integer'">validate-digits</xsl:when>
<xsl:when test="$base-type='real'">validate-number</xsl:when>
<xsl:when test="$base-type='money'">validate-number</xsl:when>
<xsl:when test="$base-type='date'">date-field validate-date</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="maxlength">
<xsl:call-template name="base-size">
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="size">
<xsl:choose>
<xsl:when test="$maxlength &gt; $max-widget-width">
<xsl:value-of select="$max-widget-width"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="concat('$instance.', @name)"/> <xsl:value-of select="$maxlength"/>
${FormHelper.HiddenField( "<xsl:value-of select="concat('instance.', @name)"/>")}
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
#else </xsl:variable>
<xsl:call-template name="widget"> <xsl:variable name="rows">
<xsl:with-param name="property" select="."/> <xsl:choose>
</xsl:call-template> <xsl:when test="$base-type = 'text'">8</xsl:when>
#end <xsl:otherwise>1</xsl:otherwise>
#else </xsl:choose>
<xsl:call-template name="widget"> </xsl:variable>
<xsl:with-param name="property" select="."/> <xsl:if test="$permission='insert' or $permission='noedit'">
</xsl:call-template> #set ( $maybe-edit="editable")
#end #if ( $instance)
#if ( <xsl:value-of select="concat( '$instance.', @name)"/>)
<xsl:choose>
<xsl:when test="$permission='insert'">
#set ( $maybe-edit="none")
</xsl:when>
<xsl:when test="$permission='noedit'">
#set ( $maybe-edit="noneditable")
</xsl:when> </xsl:when>
<!-- TODO: if $permission='insert', then you should get an editable widget if there
is no current value, else a 'not authorised' message -->
<!-- TODO: if $permission='noedit', then you should get an editable widget if there
is no current value, else just the value -->
<xsl:otherwise>
<xsl:call-template name="widget">
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose> </xsl:choose>
#set( $maybe-edit="editable")
#end
#end
</xsl:if>
${<xsl:value-of select="concat( ancestor::adl:entity/@name, 'FieldHelper')"/>.Editable( "<xsl:value-of select="concat( 'instance.', @name)"/>", "%{rendermode='<xsl:value-of select="normalize-space($render-mode)"/>',class='<xsl:value-of select="normalize-space($cssclass)"/>',title='<xsl:value-of select="normalize-space($if-missing)"/>',size='<xsl:value-of select="normalize-space($size)"/>',maxlength='<xsl:value-of select="normalize-space($maxlength)"/>',rows='<xsl:value-of select="normalize-space($rows)"/>'}")}
</td> </td>
<td class="help"> <td class="help">
<xsl:apply-templates select="adl:help[@locale = $locale]"/> <xsl:apply-templates select="adl:help[@locale = $locale]"/>
@ -1053,242 +1050,6 @@
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<!-- render an appropriate widget for the indicated property
property: a property element
-->
<xsl:template name="widget">
<xsl:param name="property"/>
<xsl:variable name="if-missing">
<xsl:choose>
<xsl:when test="adl:if-missing[@locale = $locale]">
<xsl:value-of select="adl:if-missing[@locale = $locale]"/>
</xsl:when>
<xsl:when test="$property/@required='true'">
You must provide a value for <xsl:value-of select="$property/@name"/>
</xsl:when>
<xsl:when test="$property/@type='defined'">
The value for <xsl:value-of select="$property/@name"/> must be <xsl:value-of select="$property/@definition"/>
</xsl:when>
<xsl:when test="$property/@type='entity'">
The value for <xsl:value-of select="$property/@name"/> must be an instance of <xsl:value-of select="$property/@entity"/>
</xsl:when>
<xsl:otherwise>
The value for <xsl:value-of select="$property/@name"/> must be <xsl:value-of select="$property/@type"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$property/@type='entity'">
<!-- a menu of the appropriate entity -->
<xsl:choose>
<xsl:when test="$property/@required='true'">
<!-- if required='true', then you should not get the firstoption stuff -->
#if ( $instance)
${FormHelper.Select( "instance.<xsl:value-of select="$property/@name"/>", $instance.<xsl:value-of select="$property/@name"/>, <xsl:value-of select="concat( '$all_', @name)"/>, "%{text='UserIdentifier', value='KeyString', title='<xsl:value-of select="normalize-space( $if-missing)"/>'}" )}
#else
${FormHelper.Select( "instance.<xsl:value-of select="$property/@name"/>", $<xsl:value-of select="$property/@name"/>, <xsl:value-of select="concat( '$all_', @name)"/>, "%{text='UserIdentifier', value='KeyString', title='<xsl:value-of select="normalize-space( $if-missing)"/>'}" )}
#end
</xsl:when>
<xsl:otherwise>
#if ( $instance)
${FormHelper.Select( "instance.<xsl:value-of select="$property/@name"/>", $instance.<xsl:value-of select="$property/@name"/>, <xsl:value-of select="concat( '$all_', @name)"/>, "%{firstoption='[unset]', firstoptionvalue='-1', text='UserIdentifier', value='KeyString', title='<xsl:value-of select="normalize-space( $if-missing)"/>'}" )}
#else
${FormHelper.Select( "instance.<xsl:value-of select="$property/@name"/>", $<xsl:value-of select="$property/@name"/>, <xsl:value-of select="concat( '$all_', @name)"/>, "%{firstoption='[unset]', firstoptionvalue='-1', text='UserIdentifier', value='KeyString', title='<xsl:value-of select="normalize-space( $if-missing)"/>'}" )}
#end
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$property/@type='list'">
<!-- a multi-select menu of the appropriate entity -->
${FormHelper.Select( "instance.<xsl:value-of select="$property/@name"/>", $instance.<xsl:value-of select="$property/@name"/>, <xsl:value-of select="concat( '$all_', @name)"/>, "%{multiple='multiple', size='8', text='UserIdentifier', value='KeyString', title='<xsl:value-of select="normalize-space( $if-missing)"/>'}" )}
</xsl:when>
<xsl:when test="$property/@type='defined'">
<!-- likely to be hardest of all... -->
<xsl:variable name="definition">
<xsl:value-of select="$property/@definition"/>
</xsl:variable>
<xsl:variable name="maximum">
<xsl:value-of select="//adl:definition[@name=$definition]/@maximum"/>
</xsl:variable>
<xsl:variable name="minimum">
<xsl:value-of select="//adl:definition[@name=$definition]/@minimum"/>
</xsl:variable>
<xsl:variable name="validationpattern">
<xsl:value-of select="//adl:definition[@name=$definition]/@pattern"/>
</xsl:variable>
<xsl:variable name="definedtype">
<xsl:value-of select="//adl:definition[@name=$definition]/@type"/>
</xsl:variable>
<xsl:variable name="definedsize">
<xsl:value-of select="//adl:definition[@name=$definition]/@size"/>
</xsl:variable>
<input type="text">
<xsl:variable name="cssclass">
<xsl:if test="$property/@required='true'">required </xsl:if>
<xsl:choose>
<xsl:when test="//adl:definition[@name=$definition]/@pattern">
<xsl:value-of select="concat( 'validate-custom-', $definition)"/>
</xsl:when>
<xsl:when test="//adl:definition[@name=$definition]/@minimum">
<xsl:value-of select="concat( 'validate-custom-', $definition)"/>
</xsl:when>
<xsl:when test="$definedtype='integer'">validate-digits</xsl:when>
<xsl:when test="$definedtype='real'">validate-number</xsl:when>
<xsl:when test="$definedtype='money'">validate-number</xsl:when>
<xsl:when test="$definedtype='date'">date-field validate-date</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:attribute name="class">
<xsl:value-of select="normalize-space( cssclass)"/>
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="concat( 'instance_', @name)"/>
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="concat( 'instance.', @name)"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="$definedsize &lt; 60">
<xsl:attribute name="size">
<xsl:value-of select="$definedsize"/>
</xsl:attribute>
<xsl:attribute name="maxlength">
<xsl:value-of select="$definedsize"/>
</xsl:attribute>
</xsl:when>
<xsl:when test="$definedsize &gt;= 60">
<xsl:attribute name="size">
<xsl:value-of select="60"/>
</xsl:attribute>
<xsl:attribute name="maxlength">
<xsl:value-of select="$definedsize"/>
</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:attribute name="value">
$!instance.<xsl:value-of select="$property/@name"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="normalize-space( $if-missing)"/>
</xsl:attribute>
</input>
<xsl:if test="string-length( $minimum) &gt; 0 and string-length( $maximum) &gt; 0">
<div style="width:200px; height:20px; background: transparent url(../images/slider-images-track-right.png) no-repeat top right;">
<xsl:attribute name="id">
<xsl:value-of select="concat( @name, '-track')"/>
</xsl:attribute>
<div style="position: absolute; width: 5px; height: 20px; background: transparent url(../images/slider-images-track-left.png) no-repeat top left">
<xsl:attribute name="id">
<xsl:value-of select="concat( @name, '-track-left')"/>
</xsl:attribute>
</div>
<div style="width:19px; height:20px;">
<xsl:attribute name="id">
<xsl:value-of select="concat( @name, '-slider')"/>
</xsl:attribute>
<img src="../images/slider-images-handle.png" alt="" style="float: left;" />
</div>
</div>
<script type="text/javascript" language="javascript">
// &lt;![CDATA[
new Control.Slider('<xsl:value-of select="$property/@name"/>-slider','<xsl:value-of select="$property/@name"/>-track',{
onSlide:function(v){$('<xsl:value-of select="concat( 'instance_', @name)"/>').value = <xsl:value-of select="$minimum"/>+ Math.floor(v*(<xsl:value-of select="$maximum - $minimum"/>))}
})
// ]]&gt;
</script>
</xsl:if>
<!-- TODO: generate javascript to do client-side validation -->
</xsl:when>
<xsl:when test="adl:option">
<!-- if a property has options, we definitely want a select widget-->
<select>
<xsl:attribute name="id">
<xsl:value-of select="concat( 'instance_', @name)"/>
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="concat( 'instance.', @name)"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="normalize-space( $if-missing)"/>
</xsl:attribute>
<xsl:apply-templates select="adl:option"/>
</select>
<script type="text/javascript" language="javascript">
// &lt;![CDATA[
#set ( <xsl:value-of select="concat( '$', @name, '_sel_opt')"/>="<xsl:value-of select="concat( @name, '-$instance.', @name)"/>")
option = document.getElementById( "<xsl:value-of select="concat( '$', @name, '_sel_opt')"/>");
if ( option != null)
{
option.selected = true;
}
// ]]&gt;
</script>
</xsl:when>
<xsl:when test="$property/@type='boolean'">
${FormHelper.CheckboxField( "instance.<xsl:value-of select="$property/@name"/>")}
</xsl:when>
<xsl:when test="$property/@type='date'">
<xsl:variable name="class">
<xsl:if test="$property/@required='true'">required </xsl:if>date-field validate-date
</xsl:variable>
${FormHelper.TextField( "instance.<xsl:value-of select="$property/@name"/>", "%{class='<xsl:value-of select="normalize-space( $class)"/>', textformat='d', size='10', maxlength='10'}")}
</xsl:when>
<xsl:otherwise>
<xsl:variable name="class">
<xsl:if test="$property/@required='true'">required </xsl:if>
<xsl:choose>
<xsl:when test="$property/@type='integer'">validate-digits</xsl:when>
<xsl:when test="$property/@type='real'">validate-number</xsl:when>
<xsl:when test="$property/@type='money'">validate-number</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="size">
<xsl:choose>
<xsl:when test="$property/@size &lt; 60">
<xsl:value-of select="$property/@size"/>
</xsl:when>
<xsl:when test="$property/@type='integer'">8</xsl:when>
<xsl:when test="$property/@type='real'">8</xsl:when>
<xsl:when test="$property/@type='money'">8</xsl:when>
<xsl:otherwise>60</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="maxlength">
<xsl:choose>
<xsl:when test="$property/@size &gt;= 60">
<xsl:value-of select="$property/@size"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$size"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
${FormHelper.TextField( "instance.<xsl:value-of select="$property/@name"/>", "%{class='<xsl:value-of select="$class"/>', title='<xsl:value-of select="normalize-space( $if-missing)"/>', size='<xsl:value-of select="$size"/>', maxlength='<xsl:value-of select="$maxlength"/>'}")}
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="adl:prompt">
<xsl:value-of select="@prompt"/>
</xsl:template>
<xsl:template match="adl:help">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="adl:option">
<option>
<xsl:attribute name="id"><xsl:value-of select="../@name"/>-<xsl:value-of select="@value"/></xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="@value"/>
</xsl:attribute>
<xsl:call-template name="showprompt">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="fallback" select="@value"/>
</xsl:call-template>
</option>
</xsl:template>
<!-- layout of lists --> <!-- layout of lists -->
<!-- layout of a list assuming a non-empty layout --> <!-- layout of a list assuming a non-empty layout -->
@ -1359,7 +1120,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.17 $', 10)"/> Generated using adl2listview.xsl <xsl:value-of select="substring( '$Revision: 1.18 $', 10)"/>
</xsl:comment> </xsl:comment>
<xsl:call-template name="install-scripts"/> <xsl:call-template name="install-scripts"/>
</head> </head>

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"
@ -42,6 +42,11 @@
<!-- 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:variable name="base-type">
<xsl:call-template name="base-type">
<xsl:with-param name="property" select="$property"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose> <xsl:choose>
<xsl:when test="$property/@type='defined'"> <xsl:when test="$property/@type='defined'">
<xsl:variable name="definition"> <xsl:variable name="definition">
@ -49,8 +54,20 @@
</xsl:variable> </xsl:variable>
<xsl:value-of select="/adl:application/adl:typedef[@name=$definition]/@size"/> <xsl:value-of select="/adl:application/adl:typedef[@name=$definition]/@size"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <!-- 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:value-of select="$property/@size"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$base-type"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:template> </xsl:template>