[prev in list] [next in list] [prev in thread] [next in thread] 

List:       taglibs-user
Subject:    RE: can we assign <sql:rowCount/> to a variable ??
From:       "Mader, Steve" <steve.mader () eds ! com>
Date:       2002-05-22 16:57:58
[Download RAW message or body]


It looks like you're using an older version (JDBC Tags), I'm using dbtags
which store this value in the pageContext.  You could either switch to
dbtags or possibly add something like the following to your RowCountTag and
recompile and package it:

            StatementTag stmtTag = getStatementTag();
            int rowCount = stmtTag.getTotalRowCount();
            if(rowCount == -1)
                throw new JspTagException("rowCount tag must be used inside
or after a ResultSet tag.");
            //The next line is new
Added--->   pageContext.setAttribute( "rowCount", new Integer(rowCount) );
            pageContext.getOut().write(String.valueOf(rowCount));

Then you could get the row count in your page as:

<% Integer myRowCount = (Integer)pageContext.getAttribute("rowCount"); %>


-----Original Message-----
From: sufi malak [mailto:sufi_m@hotmail.com]
Sent: Wednesday, May 22, 2002 12:27 PM
To: taglibs-user@jakarta.apache.org
Cc: steve.mader@EDS.COM
Subject: RE: can we assign <sql:rowCount/> to a variable ??


Here is the code, but can't see the Contest parameter :

// FrontEnd Plus GUI for JAD
// DeCompiled : RowCountTag.class

package org.apache.taglibs.jdbc.statement;

import java.io.IOException;
import java.io.Writer;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;

// Referenced classes of package org.apache.taglibs.jdbc.statement:
//            StatementTag

public class RowCountTag extends TagSupport
{

    public RowCountTag()
    {
    }

    public int doStartTag()
        throws JspTagException
    {
        try
        {
            StatementTag stmtTag = getStatementTag();
            int rowCount = stmtTag.getTotalRowCount();
            if(rowCount == -1)
                throw new JspTagException("rowCount tag must be used inside 
or after a ResultSet tag.");
            pageContext.getOut().write(String.valueOf(rowCount));
        }
        catch(ClassNotFoundException e)
        {
            throw new JspTagException(e.toString());
        }
        catch(IOException e)
        {
            throw new JspTagException(e.toString());
        }
        return 0;
    }

    private StatementTag getStatementTag()
        throws ClassNotFoundException
    {
        StatementTag statementTag = 
(StatementTag)TagSupport.findAncestorWithClass(this, 
Class.forName("org.apache.taglibs.jdbc.statement.StatementTag"));
        return statementTag;
    }
}


thanks


>From: "Mader, Steve" <steve.mader@eds.com>
>Reply-To: "Tag Libraries Users List" <taglibs-user@jakarta.apache.org>
>To: "'Tag Libraries Users List'" <taglibs-user@jakarta.apache.org>
>Subject: RE: can we assign <sql:rowCount/> to a variable ??
>Date: Wed, 22 May 2002 11:54:01 -0400
>
>
>You'd have to place this code inside or after the ResultSet tags because it
>is dependant on it.  If this does not work, get the source code for your
>version of dbtags and look at the RowCountTag.java program for the
>PageContext parameter name that is used for the row count.
>
>-----Original Message-----
>From: sufi malak [mailto:sufi_m@hotmail.com]
>Sent: Wednesday, May 22, 2002 11:44 AM
>To: taglibs-user@jakarta.apache.org
>Subject: RE: can we assign <sql:rowCount/> to a variable ??
>
>
>I tried it :
><% Integer myRowCount =
>(Integer)pageContext.getAttribute("org.apache.taglibs.dbtags.resultset.rowc
o
>unt");
>%>
><%=myRowCount%>
>
>BUT I got null
>
>
> >From: "Mader, Steve" <steve.mader@eds.com>
> >Reply-To: "Tag Libraries Users List" <taglibs-user@jakarta.apache.org>
> >To: "'Tag Libraries Users List'" <taglibs-user@jakarta.apache.org>
> >Subject: RE: can we assign <sql:rowCount/>  to a variable ??
> >Date: Wed, 22 May 2002 10:20:31 -0400
> >
> >
> >Try:
> >
> ><% Integer myRowCount =
>
>(Integer)pageContext.getAttribute("org.apache.taglibs.dbtags.resultset.rowc
>o
> >unt"); %>
> >
> >-----Original Message-----
> >From: sufi malak [mailto:sufi_m@hotmail.com]
> >Sent: Wednesday, May 22, 2002 10:08 AM
> >To: JSP-INTEREST@JAVA.SUN.COM
> >Cc: taglibs-user@jakarta.apache.org
> >Subject: can we assign <sql:rowCount/> to a variable ??
> >
> >
> >can we assign <sql:rowCount/> of DBtag  to a variable ??
> >thanks
> >
> >
> >
> >_________________________________________________________________
> >Send and receive Hotmail on your mobile device: http://mobile.msn.com
> >
> >
> >--
> >To unsubscribe, e-mail:
> ><mailto:taglibs-user-unsubscribe@jakarta.apache.org>
> >For additional commands, e-mail:
> ><mailto:taglibs-user-help@jakarta.apache.org>
> >
> >--
> >To unsubscribe, e-mail:
> ><mailto:taglibs-user-unsubscribe@jakarta.apache.org>
> >For additional commands, e-mail:
> ><mailto:taglibs-user-help@jakarta.apache.org>
> >
>
>
>
>
>_________________________________________________________________
>Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
>
>
>--
>To unsubscribe, e-mail:
><mailto:taglibs-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail:
><mailto:taglibs-user-help@jakarta.apache.org>
>
>--
>To unsubscribe, e-mail:   
><mailto:taglibs-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: 
><mailto:taglibs-user-help@jakarta.apache.org>
>




_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com

--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic