You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Kevin Sonney <ke...@webslingerz.com> on 2000/09/21 18:22:57 UTC

[1.8-dev patch] Global Vars in XSP - xsp:variable

ESQL has given me a new outlook on life. However, the inability to pass
<xsp:expr></xsp:expr> statements to esql has been a bit trying on one
application I'm writing. So, in a blinding flash of "wouldn't this would 
work if I had a global var, now wouldn't it?", I added the ability to
specify global variables in XSP, something that had been lacking. 

With this patch, you can do the following :

<xsp:sturcture>
	<xsp:variable>UserRecord user</xsp:variable>
	<xsp:variable>boolean debug = true</xsp:variable>
</xsp:structure>

FWIW, I *KNOW* we can do this with <xsp:logic> tags imediately after the
last <xsp:structure> tag, but using <xsp:variable>, IMHO seperates logic
from structure just that little bit further. It's also a bit clearer to
document. Especailly since the xsp docs don't talk about global vars, from
what I could see.  

Anyway, Here's the patch :

-- Cut Here - Begin 'cvs diff -u' --
Index: xsp-java.xsl
===================================================================
RCS
file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/processor/xsp/xsp-java.xsl,v
retrieving revision 1.20
diff -u -r1.20 xsp-java.xsl
--- xsp-java.xsl        2000/09/16 19:06:48     1.20
+++ xsp-java.xsl        2000/09/21 16:21:51
@@ -91,6 +91,11 @@
 
     public class <xsl:value-of select="@name"/> extends XSPPage {
       /* User Class Declarations */
+
+      <xsl:for-each select="xsp:structure/xsp:variable">
+       <xsl:value-of select="."/>;
+      </xsl:for-each>
+
       <xsl:apply-templates select="xsp:logic" />
 
       public void populateDocument(

-- Cut Here - End 'cvs diff -u' --

-- 
+-------------------------------------------+
| Kevin Sonney        kevin@webslingerZ.com |
| Systems Programmer    www.webslingerZ.com |
+-------------------------------------------+


Re: [1.8-dev patch] Global Vars in XSP - xsp:variable

Posted by Stefano Mazzocchi <st...@apache.org>.
Donald Ball wrote:
> 
> On Thu, 21 Sep 2000, Kevin Sonney wrote:
> 
> > ESQL has given me a new outlook on life. However, the inability to pass
> > <xsp:expr></xsp:expr> statements to esql has been a bit trying on one
> > application I'm writing. So, in a blinding flash of "wouldn't this would
> > work if I had a global var, now wouldn't it?", I added the ability to
> > specify global variables in XSP, something that had been lacking.
> 
> hrm? in what sense can you not pass <xsp:expr> expressions into esql?
> 
> > With this patch, you can do the following :
> >
> > <xsp:sturcture>
> >       <xsp:variable>UserRecord user</xsp:variable>
> >       <xsp:variable>boolean debug = true</xsp:variable>
> > </xsp:structure>
> >
> > FWIW, I *KNOW* we can do this with <xsp:logic> tags imediately after
> > the last <xsp:structure> tag, but using <xsp:variable>, IMHO seperates
> > logic from structure just that little bit further. It's also a bit
> > clearer to document. Especailly since the xsp docs don't talk about
> > global vars, from what I could see.
> 
> i somewhat concur here, actually, this does perhaps improve clarity. i'm
> curious to see what ricardo and stefano, and naturally, we should get in
> touch with matt sergeant before making any changes to the xsp namespace.
> someone had mentioned being able to make an xsp-dev list just for these
> issues - can that be revisited by someone with admin powers on locus?
> hello?

I'll ask the PMC to create such a list.

I think it's about time now.

I'll be back soon.

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------



Re: [1.8-dev patch] Global Vars in XSP - xsp:variable

Posted by Stefano Mazzocchi <st...@apache.org>.
Donald Ball wrote:
> 
> On Thu, 21 Sep 2000, Kevin Sonney wrote:
> 
> > On Thu, 21 Sep 2000, Donald Ball wrote:
> > > hrm? in what sense can you not pass <xsp:expr> expressions into esql?
> >
> > <page>
> > <xsp:logic>
> >       UserRecord user = new UserRecord(<response:get-parameter
> > name="user"/>);
> > </xsp:logic>
> > <esql:execute-query>
> >       &sql_driver_info;
> >       <esql:query>select meu_item from menu_list where menu_allowed =
> > <xsp:expr>user.getMenuAllowed()</xsp:expr></esql:query>
> >       <esql:results>
> >       <meuitem><esql:get-string column="menu_item"/></menuitem>
> >       </esql:results>
> > </esql:execute-query>
> >
> > will generate something along the lines of
> >
> > Class or Variable 'user' not declaired : user.getMenuAllowd()
> 
> that's strictly due to the fact that i'm using those silly interior
> methods. maybe i'll make that optional, you're not the only one to get
> bitten here... note if you're using global variables in this sense, your
> xsp page will _not_ be threadsafe.

This is the reason why we didn't have <variable> in <structure> and I
still think this is the way to go since global variables simplify your
job at first but bite you back when you turn around.

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------



Re: [1.8-dev patch] Global Vars in XSP - xsp:variable

Posted by Kevin Sonney <ke...@webslingerz.com>.
On Thu, 21 Sep 2000, Donald Ball wrote:
> that's strictly due to the fact that i'm using those silly interior
> methods. maybe i'll make that optional, you're not the only one to get
> bitten here... note if you're using global variables in this sense, your
> xsp page will _not_ be threadsafe.

Correct. And for what I'm doing, some testing might be in order.

Just out of curiosity, will the following work? 

<esql:execute-query>
	<xsp:logic>
	UserRecord user = new UserRecord(<request:get-parameter
name="username"/>);
	</xsp:logic>
	....

I mean, I can try it, but if you already know it does or it doesn't, it's
a lot faster *grin*

-- 
+-------------------------------------------+
| Kevin Sonney        kevin@webslingerZ.com |
| Systems Programmer    www.webslingerZ.com |
+-------------------------------------------+


Re: [1.8-dev patch] Global Vars in XSP - xsp:variable

Posted by Donald Ball <ba...@webslingerZ.com>.
On Thu, 21 Sep 2000, Kevin Sonney wrote:

> On Thu, 21 Sep 2000, Donald Ball wrote:
> > hrm? in what sense can you not pass <xsp:expr> expressions into esql?
> 
> <page>
> <xsp:logic>
> 	UserRecord user = new UserRecord(<response:get-parameter
> name="user"/>);
> </xsp:logic>	
> <esql:execute-query>
> 	&sql_driver_info;
> 	<esql:query>select meu_item from menu_list where menu_allowed =
> <xsp:expr>user.getMenuAllowed()</xsp:expr></esql:query>
> 	<esql:results>
> 	<meuitem><esql:get-string column="menu_item"/></menuitem>
> 	</esql:results>
> </esql:execute-query>
> 
> will generate something along the lines of 
> 
> Class or Variable 'user' not declaired : user.getMenuAllowd()

that's strictly due to the fact that i'm using those silly interior
methods. maybe i'll make that optional, you're not the only one to get
bitten here... note if you're using global variables in this sense, your
xsp page will _not_ be threadsafe.

- donald


Re: [1.8-dev patch] Global Vars in XSP - xsp:variable

Posted by Kevin Sonney <ke...@webslingerz.com>.
On Thu, 21 Sep 2000, Donald Ball wrote:
> hrm? in what sense can you not pass <xsp:expr> expressions into esql?

<page>
<xsp:logic>
	UserRecord user = new UserRecord(<response:get-parameter
name="user"/>);
</xsp:logic>	
<esql:execute-query>
	&sql_driver_info;
	<esql:query>select meu_item from menu_list where menu_allowed =
<xsp:expr>user.getMenuAllowed()</xsp:expr></esql:query>
	<esql:results>
	<meuitem><esql:get-string column="menu_item"/></menuitem>
	</esql:results>
</esql:execute-query>

will generate something along the lines of 

Class or Variable 'user' not declaired : user.getMenuAllowd()

> i somewhat concur here, actually, this does perhaps improve clarity. i'm
> curious to see what ricardo and stefano, and naturally, we should get in
> touch with matt sergeant before making any changes to the xsp namespace.

Yeah, Matt might want to see that addition, in an effort to keep things
compatable. Although Robin says not until Next release anyway, so there's
time. 

> someone had mentioned being able to make an xsp-dev list just for these
> issues - can that be revisited by someone with admin powers on locus?

+1

-- 
+-------------------------------------------+
| Kevin Sonney        kevin@webslingerZ.com |
| Systems Programmer    www.webslingerZ.com |
+-------------------------------------------+


Re: [1.8-dev patch] Global Vars in XSP - xsp:variable

Posted by Donald Ball <ba...@webslingerZ.com>.
On Thu, 21 Sep 2000, Kevin Sonney wrote:

> ESQL has given me a new outlook on life. However, the inability to pass
> <xsp:expr></xsp:expr> statements to esql has been a bit trying on one
> application I'm writing. So, in a blinding flash of "wouldn't this would 
> work if I had a global var, now wouldn't it?", I added the ability to
> specify global variables in XSP, something that had been lacking. 

hrm? in what sense can you not pass <xsp:expr> expressions into esql?

> With this patch, you can do the following :
> 
> <xsp:sturcture>
> 	<xsp:variable>UserRecord user</xsp:variable>
> 	<xsp:variable>boolean debug = true</xsp:variable>
> </xsp:structure>
> 
> FWIW, I *KNOW* we can do this with <xsp:logic> tags imediately after
> the last <xsp:structure> tag, but using <xsp:variable>, IMHO seperates
> logic from structure just that little bit further. It's also a bit
> clearer to document. Especailly since the xsp docs don't talk about
> global vars, from what I could see.

i somewhat concur here, actually, this does perhaps improve clarity. i'm
curious to see what ricardo and stefano, and naturally, we should get in
touch with matt sergeant before making any changes to the xsp namespace.
someone had mentioned being able to make an xsp-dev list just for these
issues - can that be revisited by someone with admin powers on locus?
hello?

- donald