Now with working (but very slow) user-editable internationalised messages

This commit is contained in:
sb 2008-02-27 17:38:41 +00:00
parent f28dae3038
commit 0cac7bfba9
7 changed files with 300 additions and 170 deletions

View file

@ -9,8 +9,8 @@
Transform ADL into (partial) controller classes
$Author: sb $
$Revision: 1.9 $
$Date: 2008-02-21 12:40:23 $
$Revision: 1.10 $
$Date: 2008-02-27 17:38:41 $
-->
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
@ -39,7 +39,6 @@
<!-- Whether to authenticate at application or at database layer.
If not 'Application', then 'Database'. -->
<xsl:param name="authentication-layer" select="Application"/>
<!--
The convention to use for naming auto-generated abstract primary keys. Known values are
Id - the autogenerated primary key, if any, is called just 'Id'
@ -62,7 +61,7 @@
with the revision number of the generated file if the generated file is
stored to CVS -->
<xsl:variable name="transform-rev1"
select="substring( '$Revision: 1.9 $', 11)"/>
select="substring( '$Revision: 1.10 $', 11)"/>
<xsl:variable name="transform-revision"
select="substring( $transform-rev1, 0, string-length( $transform-rev1) - 1)"/>
@ -130,6 +129,7 @@ namespace <xsl:value-of select="$controllerns"/> {
///
/// DO NOT EDIT THIS FILE!
/// &lt;/summary&gt;
[ControllerDetails("<xsl:value-of select="@name"/>", Area = "auto")]
public partial class <xsl:value-of select="@name"/>Controller : BaseController {
<xsl:if test="adl:form">
@ -312,11 +312,13 @@ namespace <xsl:value-of select="$controllerns"/> {
{
/* the session may be polluted; create a new session */
NHibernateHelper.CloseSession();
hibernator = NHibernateHelper.GetCurrentSession(Session[ NHibernateHelper.USERTOKEN],
Session[NHibernateHelper.PASSTOKEN]);
}
<xsl:call-template name="menus">
hibernator = NHibernateHelper.GetCurrentSession(<xsl:if test="$authentication-layer = 'Database'">
Session[ NHibernateHelper.USERTOKEN],
Session[NHibernateHelper.PASSTOKEN]
</xsl:if>);
}
<xsl:call-template name="menus">
<xsl:with-param name="entity" select="."/>
</xsl:call-template>
RenderViewWithFailover("<xsl:value-of select="concat( adl:form[position()=1]/@name, '.vm')"/>",
@ -422,8 +424,8 @@ namespace <xsl:value-of select="$controllerns"/> {
if ( Form[ "<xsl:value-of select="concat( 'instance.', @name)"/>" ] == null)
{
AddError( <xsl:choose>
<xsl:when test="ifmissing[@locale=$locale]">
<xsl:apply-templates select="ifmissing[@locale=$locale]"/>
<xsl:when test="adl:ifmissing[@locale=$locale]">
<xsl:apply-templates select="adl:ifmissing[@locale=$locale]"/>
</xsl:when>
<xsl:otherwise>"You must supply a value for <xsl:value-of select="@name"/>"</xsl:otherwise>
</xsl:choose>);
@ -455,13 +457,13 @@ namespace <xsl:value-of select="$controllerns"/> {
[AccessibleThrough(Verb.Post)]
public void <xsl:value-of select="concat( @name, 'SubmitHandler')"/>( )
{
string command = Form[ "command"];
string command = Form[ "command"];
if ( command == null)
{
throw new Exception( "No command?");
}
else
if ( command == null)
{
throw new Exception( "No command?");
}
else
<xsl:for-each select=".//verb">
if ( command.Equals( "<xsl:value-of select="@verb"/>"))
{
@ -521,16 +523,26 @@ namespace <xsl:value-of select="$controllerns"/> {
/// &lt;summary&gt;
/// Show the form named <xsl:value-of select="@name"/>, containing the indicated record
/// &lt;/summary&gt;
/// &lt;param name="<xsl:value-of select="concat( ../@name, 'Id')"/>"&gt;the key value of the record to show&lt;/param&gt;
<xsl:for-each select="ancestor::adl:entity/adl:key/adl:property">
/// &lt;param name="<xsl:value-of select="@name"/>"&gt;the key value of the record to show&lt;/param&gt;
</xsl:for-each>
[AccessibleThrough(Verb.Get)]
public void <xsl:value-of select="@name"/>( <xsl:value-of select="concat($keytype, ' ', ../@name, 'Id')"/>)
public void <xsl:value-of select="@name"/>( <xsl:for-each select="ancestor::adl:entity/adl:key/adl:property">
<xsl:call-template name="csharp-type">
<xsl:with-param name="property" select="."/>
</xsl:call-template>
<xsl:value-of select="concat( ' ', @name)"/>
<xsl:if test="not( position() = last())">,</xsl:if>
</xsl:for-each>)
{
ISession hibernator =
NHibernateHelper.GetCurrentSession( <xsl:if test="$authentication-layer = 'Database'">Session[ NHibernateHelper.USERTOKEN],
Session[NHibernateHelper.PASSTOKEN]</xsl:if>);
<xsl:value-of select="concat($entityns, '.', ancestor::adl:entity/@name)"/> record =
hibernator.CreateCriteria(typeof(<xsl:value-of select="concat($entityns, '.', ancestor::adl:entity/@name)"/>))
.Add(Expression.Eq("<xsl:value-of select="$key"/>", <xsl:value-of select="../@name"/>Id))
<xsl:for-each select="ancestor::adl:entity/adl:key/adl:property">
.Add(Expression.Eq("<xsl:value-of select="@name"/>", <xsl:value-of select="@name"/>))
</xsl:for-each>
.UniqueResult&lt;<xsl:value-of select="concat($entityns, '.', ancestor::adl:entity/@name)"/>&gt;();
<xsl:if test="$authentication-layer = 'Database'">