cmu.survey.jsp.tags
Class DatabaseUpdate

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by cmu.survey.jsp.tags.TagSupportAndMore
          extended by cmu.survey.jsp.tags.DatabaseList
              extended by cmu.survey.jsp.tags.DatabaseUpdate
All Implemented Interfaces:
java.io.Serializable, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.Tag, javax.servlet.jsp.tagext.TryCatchFinally

public class DatabaseUpdate
extends DatabaseList

A subclassable tag for inserting, updating and deleting records from a database. It reads the information straight from the form in the request object, if a form was submitted.

GenericUpdate is a more generic subclass of DatabaseUpdate.
If you are using the <survey:Survey> tag, you won't need to use either of these -- GenericUpdate is automatically called from the Survey tag.

See Also:
Serialized Form

Field Summary
protected  int currentMode
           
protected static int dbDelete
           
protected static int dbInsert
          Some constants for the mode we are in
protected  java.lang.String dbTable
          The name of the table we are changing
protected static int dbUpdate
           
static java.lang.String[] monthArray
          A (handy) array of month names
protected  javax.servlet.http.HttpServletRequest theRequest
          The request object from the page
static java.lang.String[] weekdayArray
          A (handy) array of weekday names
protected  java.lang.String whereClause
          The string that will uniquely identify the record
 
Fields inherited from class cmu.survey.jsp.tags.DatabaseList
auxResultSet, databaseConnection, field, fieldsToShowArray, out, queryObjectName, resultSet, returnMessage, select, theConnection
 
Fields inherited from class cmu.survey.jsp.tags.TagSupportAndMore
dateFormatAmerican, dateTimeFormatAmerican, DAYS_OF_THE_WEEK, debug, MONTHS_OF_THE_YEAR, timeFormatAmerican
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
DatabaseUpdate()
           
 
Method Summary
 java.lang.String assembleDate(java.lang.String theMonth, java.lang.String theDay, java.lang.String theYear)
          Takes the names of 3 paramaters, grabs them from the request and returns them stuck together with slashes between them.
 java.lang.String assembleDateSQL(java.lang.String theMonth, java.lang.String theDay, java.lang.String theYear)
           
protected  void cleanExecute(java.lang.String SQLstring)
          Appends the where clause and executes the query
 int doStartTag()
           
protected  java.lang.String fixSQLString(java.lang.String aStringParam)
          Fixes a string for insertion into a database - removes apostrophes ("'") Use fixSQLString2 to remove semicolons too, whenever possible.
static java.lang.String fixSQLString2(java.lang.String aStringParam)
          Fixes a string for insertion into a database - escapes apostrophes and backslashes.
protected  void initAttributes()
           
protected static java.lang.String nullEmpty(java.lang.String theParameter)
          This function takes a string and returns the string "null" if it is empty.
 void reinit()
           
 
Methods inherited from class cmu.survey.jsp.tags.DatabaseList
close, doAuxillaryQuery, doEndTag, doQuery, finalize, formatDateMySQL, formatDateSQL, formatDateSQL, formatDateSQLFromHTML, formatDateTimeSQL, formatDateTimeSQL, formatDateTimeSQL, formatTimeMySQL, formatTimeSQL, formatTimeSQL, getAuxDatabaseQuery, getCalendar, getDatabaseConnection, getDatabaseQuery, getDateField, getDateFieldCal, getDateFrom, getDateTimeCalendarField, getDateTimeField, getEndWith, getField, getField, getFields, getFields, getFieldToPassInLink, getIntField, getLastExceptionThrown, getLinkTo, getList, getOneLine, getOptionTag, getQueryObjectName, getSaveAsSession, getSendErrorMessages, getSQLTimeField, getStartWith, getTheConnection, getTimeField, getTimeFieldCal, getTimestampField, isCurrentItemInAuxQuery, isDatabaseOpen, moveToNextAuxillaryRecord, moveToNextRecord, parseDateFromSQL, parseDateTimeCalendarFromSQL, parseDateTimeFromSQL, parseDateTimeFromSQL, parseTimeFromSQL, printList, printOneLine, resetFieldsForNextRecord, returnOneLine, saveErrorMessage, saveErrorMessage, setAuxDatabaseQuery, setDatabaseQuery, setEndWith, setField, setFieldToPassInLink, setLinkTo, setOptionTag, setQueryObjectName, setSaveAsSession, setSendErrorMessages, setStartWith, setupConnection, setupConnection
 
Methods inherited from class cmu.survey.jsp.tags.TagSupportAndMore
breakDownToArray, convertDayNameToNum, convertDayNumToName, convertDayNumToName, convertMonthNumToName, doCatch, doFinally, formatDateTimeViewable, formatDateTimeViewable, formatDateViewable, formatTimeNoSecondsViewable, formatTimeNoSecondsViewable, formatTimeNoSecondsViewable, getNumDaysInWeek, parseTimeNoSecondsFromViewable, print, println
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbTable

protected java.lang.String dbTable
The name of the table we are changing


whereClause

protected java.lang.String whereClause
The string that will uniquely identify the record


dbInsert

protected static final int dbInsert
Some constants for the mode we are in

See Also:
Constant Field Values

dbUpdate

protected static final int dbUpdate
See Also:
Constant Field Values

dbDelete

protected static final int dbDelete
See Also:
Constant Field Values

currentMode

protected int currentMode

theRequest

protected javax.servlet.http.HttpServletRequest theRequest
The request object from the page


monthArray

public static final java.lang.String[] monthArray
A (handy) array of month names


weekdayArray

public static final java.lang.String[] weekdayArray
A (handy) array of weekday names

Constructor Detail

DatabaseUpdate

public DatabaseUpdate()
Method Detail

initAttributes

protected void initAttributes()

doStartTag

public int doStartTag()
Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class DatabaseList

cleanExecute

protected void cleanExecute(java.lang.String SQLstring)
Appends the where clause and executes the query


nullEmpty

protected static java.lang.String nullEmpty(java.lang.String theParameter)
This function takes a string and returns the string "null" if it is empty. This is used for inserting null values in a SQL string.


fixSQLString

protected java.lang.String fixSQLString(java.lang.String aStringParam)
Fixes a string for insertion into a database - removes apostrophes ("'") Use fixSQLString2 to remove semicolons too, whenever possible.


fixSQLString2

public static final java.lang.String fixSQLString2(java.lang.String aStringParam)
Fixes a string for insertion into a database - escapes apostrophes and backslashes. Handles: ' \


assembleDate

public java.lang.String assembleDate(java.lang.String theMonth,
                                     java.lang.String theDay,
                                     java.lang.String theYear)
Takes the names of 3 paramaters, grabs them from the request and returns them stuck together with slashes between them.


assembleDateSQL

public java.lang.String assembleDateSQL(java.lang.String theMonth,
                                        java.lang.String theDay,
                                        java.lang.String theYear)

reinit

public void reinit()
Overrides:
reinit in class DatabaseList