tcurdt 02/01/28 01:37:17
Modified: src/java/org/apache/cocoon/components/language/markup/xsp
EsqlQuery.java
src/java/org/apache/cocoon/components/language/markup/xsp/java
esql.xsl
Log:
added support for getting the complete row count
(for a link to the last page when paging)
Revision Changes Path
1.2 +24 -0
xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/EsqlQuery.java
Index: EsqlQuery.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/EsqlQuery.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EsqlQuery.java 3 Jan 2002 12:31:10 -0000 1.1
+++ EsqlQuery.java 28 Jan 2002 09:37:16 -0000 1.2
@@ -184,6 +184,30 @@
return(this.hasResultSet);
}
+ public int rowCount() throws SQLException {
+ switch(limitMethod) {
+ case EsqlConnection.LIMIT_METHOD_JDBC:
+ // TC: I'm not quite sure if synchronized is really necessary since
+ // the XSP page will be poolable
+ synchronized (resultSet) {
+ int currentRow = resultSet.getRow();
+ resultSet.last();
+ int count = resultSet.getRow();
+ if (currentRow > 0) {
+ resultSet.absolute(currentRow);
+ }
+ else {
+ resultSet.first();
+ resultSet.relative(-1);
+ }
+ return(count);
+ }
+ default:
+ // select count(*)
+ throw new RuntimeException("not yet implemented");
+ };
+ }
+
public void getResultRows() throws SQLException {
resultSet = statement.getResultSet();
resultSetMetaData = resultSet.getMetaData();
1.4 +5 -1
xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl
Index: esql.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- esql.xsl 8 Jan 2002 11:39:47 -0000 1.3
+++ esql.xsl 28 Jan 2002 09:37:16 -0000 1.4
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<!-- $Id: esql.xsl,v 1.3 2002/01/08 11:39:47 tcurdt Exp $-->
+<!-- $Id: esql.xsl,v 1.4 2002/01/28 09:37:16 tcurdt Exp $-->
<!--
============================================================================
@@ -559,6 +559,10 @@
</xsl:template>
<xsl:template match="esql:query//esql:parameter">"?"</xsl:template>
+
+<xsl:template match="esql:execute-query//esql:results//esql:row-count">
+ <xsp:expr>_esql_query.rowCount()</xsp:expr>
+</xsl:template>
<xsl:template match="esql:execute-query//esql:results">
<xsp:content>
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]