cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Ball <ba...@webslingerZ.com>
Subject RE: [C2] xsp:logic tag behaviour
Date Wed, 10 Jan 2001 02:56:05 GMT
On Tue, 9 Jan 2001, Vadim Gritsenko wrote:

> Sorry to hear this... But - correct me if I don't understand this -
> it is possible to re-write logicsheet so it uses variables only
> inside scope of <xsp:logic> tag, example:
> ------------- existing code --------------
>       <xsp:logic>
>         Stack esqlSessions = new Stack();
>         EsqlSession esqlSession = null;
>       </xsp:logic>
>       <xsl:apply-templates/>
> -------------- replace by ----------------
>       <xsp:logic>
>         Stack esqlSessions = new Stack();
>         EsqlSession esqlSession = null;
>         <xsp:content>
>           <xsl:apply-templates/>
>         </xsp:content>
>       </xsp:logic>
> ------------------------------------------
>
> And the code will be a little bit clearer (at least, you can see
> variable scope - so you know where this variable may be used) - of
> course, this is objective.

no. some variables declared in an xsp:logic element may be used in
expressions which are used outside of the xsp:logic element. if you want
your variables to lose scope after your xsp:logic element ends, put curly
braces inside your xsp:logic element (<xsp:logic>{ ... }</xsp:logic>).

> > They rely on the ability to create variables which continue after the
> > xsp:logic tag ends - one of the few technical advantages which
> > XSP has over plain Java.
>
> But now, if your tag declares variable - you can not use this tag again in
> same jsp - or you must do some sort of variable name generation.

that's why well-behaved logicsheets, e.g. esql, mail, smtp, put a prefix
(_esql_) on variables they declare. yeah, i can see some rationale for an
xsp:variable element so that this process is automatic, but others have
disagreed so far.

- donald


Mime
View raw message