tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jim Cobban" <jcob...@magma.ca>
Subject Re: Please respond, I am at a roadblock, Tomcat cannot find sette r method
Date Tue, 19 Nov 2002 15:49:04 GMT
----- Original Message -----
From: "Wendy Smoak" <Wendy.Smoak@asu.edu>
Subject: RE: Please respond, I am at a roadblock, Tomcat cannot find sette r
method


> In particular, Craig's reply on 11/14 listed some possible problems and
> asked to see the get/set methods in the base class.  The fact that this
> starts working when you use _other_ method names probably means that there
> is something wrong with the existing methods.  I don't see where you have
> posted code from the base class yet.  That might help.

I did post the code of the set methods in the base class.

Furthermore I have received a reply from another user that he encountered
the same problem with an attribute "class" which he had to rename to "clasz"
in order to get it to work.

The ONLY thing I changed between the version that failed and the version
that worked was the names of the attributes and the corresponding set
methods.  I did not change one character of the code in the methods.   If
you are not satisfied with that here is the entire base class with nothing
changed but the names of the set methods:

/**
 * QueryTag.java
 *
 * This tag implements a query of the census data database and encapsulates
 * a tabular display of the data.  This is the base class for tag classes
 * which will exploit the row tag and field tag to display the results of
 * a query.  In order to use the row tag the first two fields requested in
the
 * SELECT verb must be the district number and the subdistrict identifier
 * since the class RowTag assumes that in order to extract the county
 * identifier and subdistrict name from the subdistrict table.
 *
 * &copy; 2002 James Cobban
 */

package Census.tags;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
import java.sql.*;
import Census.ConnectionPool;


public class QueryTag extends TagSupport
{
  static protected final int ENGLISH = 0;
  static protected final int FRENCH = 1;
  private int Language;

  static private final String[] LangCode = {"En", "Fr"};

  // LangTag.setLang
  //
  // handles an attribute which sets the language to be used in text
  // displayed to the user

  public void setLing(String lang)
  {
      if ((lang != null) && lang.equalsIgnoreCase("FR"))
 Language = FRENCH;
      else
 Language = ENGLISH;
  }  // LangTag.setLang

  public int getLang()
  {
    return Language;
  }

  public String getLangCode()
  {
    return LangCode[Language];
  }
    // local members of the class

    // limit on number of rows to display

    private int maxRows = 50;

    // QueryTag.setMaxRows
    //
    // handles an attribute which sets the maximum number of rows to display
    // from the database

    public void setMaxRoz(String repeats)
    {
 try
 {
     maxRows = Integer.parseInt(repeats);
 }
 catch(NumberFormatException nfe)
 {
     maxRows = 50;
 }
    }  // QueryTag.setMaxRows

    // QueryTag.getMaxRows
    //
    // returns the maximum number of rows to display

    public int getMaxRows()
    {
 return maxRows;
    }

    protected String where;  // the where clause of the query

    protected ConnectionPool connectionPool;
    protected Connection connection;

    public Connection getConnection()
    {
 return connection;
    }

    protected int  rowCount; // number of rows in the result

    public int getRowCount()
    {
 return rowCount;
    }

    protected int  row;   // starting row in the result

    public int getRow()
    {
 return row;
    }

    protected String pageName; // page this tag is on

    public String getPageName()
    {
 return pageName;
    }

    protected ResultSet resultSet; // result of query

    public ResultSet getResultSet()
    {
 return resultSet;
    }

    // QueryTag.addParmToWhere
    //
    // This method performs standard actions to add a search argument to
    // the "where" clause of the query

    protected void addParmToWhere(ServletRequest request,
        String  parmName,
    String  dbName)
    {
 String value = request.getParameter(parmName);
 if ((value != null) && (value.length() > 0))
 {  // parameter supplied
     if (!value.equalsIgnoreCase("Any"))
     {
  if (where.length() > 0)
      where += " AND ";
  where   += dbName + "=\"" + value + "\"";
     }
 }  // parameter supplied
    }  // QueryTag.addParmToWhere

    // QueryTag.addIntParmToWhere
    //
    // This method performs standard actions to add a numeric search
argument
    // to the "where" clause of the query
    //
    // Returns: numeric value of parameter

    protected int addIntParmToWhere(ServletRequest request,
          String  parmName,
      String  dbName)
       throws NumberFormatException
    {
      int rc = 0;
      String value = request.getParameter(parmName);
      if ((value != null) && (value.length() > 0))
      {
          if (where.length() > 0)
           where += " AND ";
          where   += dbName + "=" + value;
   rc = Integer.parseInt(value);
      }
      return rc;
    }  // QueryTag.addIntParmToWhere

    // QueryTag.getRow
    //
    // This method gets the row number in the response at which display is
to
    // start.  As a side effect it sets the "row" member so that the public
    // getRow method will work.  It must be called by the doStartTag method
    // to perform that initialization.

    protected int getRow(ServletRequest request)
    {
 String Row = request.getParameter("Row");
 if ((Row != null) && (Row.length() > 0))
 {  // the Row parameter was specified
     try
     {  // convert the string to integer
  row = Integer.parseInt(Row);
     }  // convert the string to integer
     catch(NumberFormatException ne)
     {  // invalid format
  System.out.println("Row parameter not numeric");
  row = 0;
     }  // invalid format

     return row;
 }  // the Row parameter was specified
 return 0;
    }  // QueryTag.getRow

}  // class QueryTag




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


Mime
View raw message