jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From morg...@apache.org
Subject cvs commit: jakarta-taglibs/dbtags/src/org/apache/taglibs/dbtags/resultset RowCountTag.java WasEmptyTag.java WasNotEmptyTag.java
Date Wed, 15 Aug 2001 00:45:53 GMT
morgand     01/08/14 17:45:53

  Modified:    dbtags/src/org/apache/taglibs/dbtags/resultset
                        RowCountTag.java WasEmptyTag.java
                        WasNotEmptyTag.java
  Log:
  rowCount, wasEmpty and wasNotEmpty can be used outside of statement tags
  
  Revision  Changes    Path
  1.3       +10 -25    jakarta-taglibs/dbtags/src/org/apache/taglibs/dbtags/resultset/RowCountTag.java
  
  Index: RowCountTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/dbtags/src/org/apache/taglibs/dbtags/resultset/RowCountTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RowCountTag.java	2001/07/02 18:19:45	1.2
  +++ RowCountTag.java	2001/08/15 00:45:52	1.3
  @@ -55,7 +55,7 @@
    * <http://www.apache.org/>.
    *
    */
  -package org.apache.taglibs.dbtags.statement;
  +package org.apache.taglibs.dbtags.resultset;
   
   import java.io.IOException;
   
  @@ -67,7 +67,7 @@
    * It can be used inside a ResultSet tag to provide a running
    * count of rows retreived, or after the ResultSet tag to
    * display the total number.  Using the tag before the ResultSet
  - * or outside of a Statement or PreparedStatement will
  + * will
    * produce an error.</p>
    * 
    * <p>JSP Tag Lib Descriptor
  @@ -79,7 +79,7 @@
    * It can be used inside a ResultSet tag to provide a running
    * count of rows retreived, or after the ResultSet tag to
    * display the total number.  Using the tag before the ResultSet
  - * or outside of a Statement or PreparedStatement will
  + *  will
    * produce an error.&lt;/info>
    * </pre>
    * 
  @@ -88,32 +88,17 @@
    */
   public class RowCountTag extends TagSupport {
   
  -  /**
  -   * Get the enclosing StatementTag tag
  -   * 
  -   * @return StatementTag
  -   * @exception ClassNotFoundException
  -   */
  -  private StatementTag getStatementTag() throws ClassNotFoundException {
  -    StatementTag statementTag = 
  -    (StatementTag) findAncestorWithClass(this, Class.forName("org.apache.taglibs.dbtags.statement.StatementTag"));
  -    return statementTag;
  -  }
  -
     public int doStartTag() throws JspTagException {
  -
  -    try {
  -      StatementTag stmtTag = getStatementTag();
   
  -      int rowCount = stmtTag.getTotalRowCount();
  +    Integer integer = 
  +      (Integer) pageContext.getAttribute("org.apache.taglibs.dbtags.resultset.rowcount");
   
  -      if (rowCount == -1) {
  -        throw new JspTagException("rowCount tag must be used inside or after a ResultSet
tag.");
  -      }
  +    if (integer == null) {
  +      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());
  +    try {
  +      pageContext.getOut().write(integer.toString());
       } catch (IOException e) {
         throw new JspTagException(e.toString());
       }
  
  
  
  1.3       +22 -35    jakarta-taglibs/dbtags/src/org/apache/taglibs/dbtags/resultset/WasEmptyTag.java
  
  Index: WasEmptyTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/dbtags/src/org/apache/taglibs/dbtags/resultset/WasEmptyTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WasEmptyTag.java	2001/07/02 18:19:47	1.2
  +++ WasEmptyTag.java	2001/08/15 00:45:52	1.3
  @@ -56,7 +56,7 @@
    * <http://www.apache.org/>.
    *
    */
  -package org.apache.taglibs.dbtags.statement;
  +package org.apache.taglibs.dbtags.resultset;
   
   import javax.servlet.jsp.JspTagException;
   import javax.servlet.jsp.tagext.TagSupport;
  @@ -100,41 +100,28 @@
       _value = value;
     }
   
  -  /**
  -   * Get the enclosing StatementTag tag
  -   * 
  -   * @return StatementTag
  -   * @exception ClassNotFoundException
  -   */
  -  private StatementTag getStatementTag() throws ClassNotFoundException {
  -    StatementTag statementTag = 
  -    (StatementTag) findAncestorWithClass(this, Class.forName("org.apache.taglibs.dbtags.statement.StatementTag"));
  -    return statementTag;
  -  }
  -
     public int doStartTag() throws JspTagException {
  -    try {
  -      StatementTag stmtTag = getStatementTag();
  -      int rowCount = stmtTag.getTotalRowCount();
  -
  -      if (rowCount == -1) {
  -        throw new JspTagException("WasEmpty and WasNotEmpty tags must follow a ResultSet
tag.");
  -      }
  -
  -      boolean wasEmpty = true;
  -      if (rowCount > 0) {
  -        wasEmpty = false;
  -      }
  -
  -      // evaluate the body only if wasEmpty matches the desired
  -      // value (true or false)
  -      if (wasEmpty == _value) {
  -        return EVAL_BODY_INCLUDE;
  -      } else {
  -        return SKIP_BODY;
  -      }
  -    } catch (ClassNotFoundException e) {
  -      throw new JspTagException(e.toString());
  +
  +    Integer integer = 
  +      (Integer) pageContext.getAttribute("org.apache.taglibs.dbtags.resultset.rowcount");
  +    
  +    if (integer == null) {
  +      throw new JspTagException("WasEmpty and WasNotEmpty tags must follow a ResultSet
tag.");
  +    }
  +
  +    int rowCount = integer.intValue();
  +
  +    boolean wasEmpty = true;
  +    if (rowCount > 0) {
  +      wasEmpty = false;
  +    }
  +
  +    // evaluate the body only if wasEmpty matches the desired
  +    // value (true or false)
  +    if (wasEmpty == _value) {
  +      return EVAL_BODY_INCLUDE;
  +    } else {
  +      return SKIP_BODY;
       }
     }
   
  
  
  
  1.3       +1 -1      jakarta-taglibs/dbtags/src/org/apache/taglibs/dbtags/resultset/WasNotEmptyTag.java
  
  Index: WasNotEmptyTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/dbtags/src/org/apache/taglibs/dbtags/resultset/WasNotEmptyTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WasNotEmptyTag.java	2001/07/02 18:19:48	1.2
  +++ WasNotEmptyTag.java	2001/08/15 00:45:52	1.3
  @@ -56,7 +56,7 @@
    * <http://www.apache.org/>.
    *
    */
  -package org.apache.taglibs.dbtags.statement;
  +package org.apache.taglibs.dbtags.resultset;
   
   
   /**
  
  
  

Mime
View raw message