cocoon-users mailing list archives

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

Alex.

----- Original Message -----
From: "Christian Haul" <haul@dvs1.informatik.tu-darmstadt.de>
To: "Alexander Smirnoff" <asmirnoff@vistar.ca>
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>
transformation
>
> > 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
for
> > 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 ....>
<system:response>
...
id=<lib:asset action="get-id" name="vd2222"/>
...
</system:response>
</xsp:page>

in logicsheet:

<xsl:template match="system:response">
        <xsp:logic>
                private int assetGetID(String name)
                {
                int ID=0;
                <esql:connection>
                <esql:pool>system_pool</esql:pool>
                <esql:execute-query>
                    <esql:query>
                        <xsp:expr>"select id from asset where
name='"+name+"'"</xsp:expr>
                    </esql:query>
                    <esql:results>
                        <esql:row-results>
                            <xsp:logic>
                                 ID=<xsp:expr><esql:get-int
column="id"/></xsp:expr>;
                            </xsp:logic>
                        </esql:row-results>
                    </esql:results>
                </esql:execute-query>
                </esql:connection>
                return ID;
                }
       </xsp:logic>
       <xsl:element name="SystemResponse">
              <xsl:apply-templates/>
       </xsl:element>
</xsl:template>
....
<xsl:template match="gwvas:asset[@action='get-id']">
        this.assetGetID(<xsl:value-of select="@name"/>)
</xsl:template>


> Chris.
>
> --
> C h r i s t i a n       H a u l
> haul@informatik.tu-darmstadt.de
>     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. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message