cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Ball <ba...@webslingerZ.com>
Subject Re: News site with XSP and SQL. (fwd)[C1][C2] variables in XSP
Date Tue, 16 Jan 2001 07:03:38 GMT
On Fri, 12 Jan 2001, Tagunov Anthony wrote:

> >i suppose i should offer an alternate suggestion. we've kicked around the
> >idea before of adding an xsp:variable element to the xsp language.
> >something like this:
> >
> ><xsp:logic>
> >  <xsp:variable type="String" name="name">"foo"</xsp:variable>
> >  ...
> ></xsp:logic>
> >
> >would turn into
> >
> >String name = "foo";
> >
> >then you could have utility methods, not necessarily part of the xsp
> >language proper, which would generate method headers and calls:
> >
> ><xsl:template match="util:generate-method-header">
> >  <xsl:param name="name"/>
> >  <xsl:param name="type"/>
> >  <xsl:value-of select="$type"/>
> >  <xsl:text> </xsl:text>
> >  <xsl:value-of select="$name"/>
> >  <xsl:text>(HttpServletResponse response, ...</xsl:text>
> >  <xsl:for-each select="//xsp:variable">
> >    <xsl:text>,<xsl:text>
> >    <xsl:value-of select="@type"/>
> >    <xsl:text> </xsl:text>
> >    <xsl:value-of select="@name"/>
> >  </xsl:for-each>
> >  <xsl:text>) </xsl:text>
> ></xsl:template>
> >
> >if anyone thinks this is a good compromise solution, i'll try to prototype
> >something more comprehensive.
>
> Excuse my being too persistent.. To me (a green novice :) it looks
> good! (As far as I understand what we want is single Schemo for
> various languages, isn't it?)  And surely there should be something to
> add additional parameters to the method (f.e. I've got a method void
> sendEmail(String email, String password), so I'd like additional
> arguments (email and password there). And we need a way to generate
> invocations for these methods!

i just checked in experimental support for this for c1. you declare
variables using the xsp:variable element:

<xsp:element name="foo" type="String"/>

they're set to null by default, but you can give a value attribute to
initialize if you want. you can generate and call methods like so:

<xsp:page>
  <xsp:logic>
    <util:generate-method-header name="myMethod" returns="void"/> {
       ...
    }
  </xsp:logic>
  <page>
    <xsp:logic>
      <util:call-method name="myMethod"/>;
    </xsp:logic>
  </page>
</xsp:page>

i'm interested to hear what people think.

- donald


Mime
View raw message