cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Smirnoff" <>
Subject Re: Esql in Logicsheets
Date Tue, 16 Oct 2001 20:20:39 GMT
Thanks Chris for your reply, commenst are follows:


----- Original Message -----
From: "Christian Haul" <>
To: "Alexander Smirnoff" <>
Sent: Tuesday, October 16, 2001 3:02 PM
Subject: Re: Esql in Logicsheets

> On 16.Oct.2001 -- 11:46 AM, Alexander Smirnoff wrote:
> > It doesn't compile and the error message is: "Can't convert void to
int". So
> > I guess something wrong happens when <esql:...>/<xsp:expr>
> > ID = if (_esql_connection != null) {
> >           _esql_connections.push(_esql_connection);
> > }
> >
> > _esql_connection = new EsqlConnection();
> > try {
> > ....
> > which seems quite nonsense to me. So the dilemma is: should I use ESQL
> > such cases at all? May be any workaround exist?
> OK, this is nonsense, indeed. It seems that too many <xsp:expr>
> irritate the xsp logicsheet. But why does it try to get a new
> connection?

I guess because I'm asking it to do so in <esql:connection> clause. The
thing is that I'm using this clause in logicsheet, which will be transformed
in statement from the source XSP (remember? ID=<lib:asset action="get-id"
name="vd2222"/>). I hoped that in <esql:*> transformations this will be
transformed in something more intelligent, but it does not, as you see.

> Anyway, try to remove the extra xsp:expr around esql:get-int. If that
> doesn't help, please send full source i.e. create the smallest xsp +
> xsl that still exhibits your problem (ideally against the demo DB)
> plus cocoon.xconf snippet (logicsheet declaration).

I'd tried removing/adding expr and logic tags, but it seems that it just not
the way to be impemented... (you still have to "executeQuery" between "ID="
and "ResultSet.getInt" method. May be I'm wrong about that...)

> As someone else put it, you don't need to do string operations to get
> your ID into the query string since taglibs work on a textual basis
> long before javac sees the code. So you could just
>  Query = "select foo from bar where id=<xsl:copy-of select="@ID"/>";
> while
>  Query = "select foo from bar where id=<esql:get-int name="ID"/>";
> won't work. The first might not be you intention, anyway, because the
> query is static (determined once when the taglib is applied first,
> afterwards it's fixed for every request)

Yes. You're right. Thanks for the tip.

> Another workaround might be to use esql:parameter with the additional
> advantage that it uses a prepared statement instead.

What is esql:parameter and how can I use it?

Meanwhile I found a workaround. In logicsheet I'm defining private method,
say assetGetID(String name), on the class level, which embodies the <esql:*>
clause. And substitute <lib:asset action="get-id" name="vd2222"/> with only
the call to this function i.e. this.assetGetID(<xsl:value-of
select="@name"/>). It works perfect.

Here is the snippet:

in XSP file:

<xsp:page ....>
id=<lib:asset action="get-id" name="vd2222"/>

in logicsheet:

<xsl:template match="system:response">
                private int assetGetID(String name)
                int ID=0;
                        <xsp:expr>"select id from asset where
                return ID;
       <xsl:element name="SystemResponse">
<xsl:template match="gwvas:asset[@action='get-id']">
        this.assetGetID(<xsl:value-of select="@name"/>)

> Chris.
> --
> C h r i s t i a n       H a u l
>     fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

Please check that your question has not already been answered in the
FAQ before posting. <>

To unsubscribe, e-mail: <>
For additional commands, e-mail: <>

View raw message