cmu.survey.jsp.tags
Class Survey

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by cmu.survey.jsp.tags.DatabaseConnection
          extended by cmu.survey.jsp.tags.Survey
All Implemented Interfaces:
SurveyDataCache, java.io.Serializable, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.Tag, javax.servlet.jsp.tagext.TryCatchFinally
Direct Known Subclasses:
SurveyBlank

public class Survey
extends DatabaseConnection
implements SurveyDataCache

Survey is the main tag to go around all surveys/webforms you make.
Here's some sample code:
<%@ taglib uri="/WEB-INF/SurveyTags.tld" prefix="survey" %>
<survey:survey databaseName="<%=databaseName%>" table="tbladmin">
</survey:survey>

Survey's superclass, DatabaseConnection, takes care of starting up the database. See it for info on how to connect to a database with the parameter databaseName.

Choose the table you want to save/load the data into with the "table" field. Every other parameter is optional.

Between the <survey:survey> and </survey:survey> you can put as many Questions as you want.

See Also:
Serialized Form

Field Summary
static java.lang.String BackgroundColor1Default
           
static java.lang.String BackgroundColor2Default
           
static java.lang.String clearBackgroundColorDefault
           
protected  java.lang.String countTimesVisitingPageField
           
protected  boolean createUsersAtLogin
           
protected  DatabaseQuery databaseQuery
           
protected  DataStorage dataStorage
           
protected static boolean debug
           
protected  java.lang.String deleteImage
           
protected  java.lang.String deleteImageDown
           
protected  java.lang.String deleteImageRollover
           
protected  java.lang.String emailResultsSubjectLine
           
protected  java.lang.String emailResultsTo
           
protected  int fontSize
           
protected static int fontSizeDefault
           
static java.lang.String HeaderBackgroundColorDefault
           
protected  boolean ignoreWrongTechniqueError
           
protected  boolean isLoginPage
           
protected  boolean neverMakeNewRecord
           
protected  java.lang.String nextPage
           
protected  java.lang.String nextPageIfDeleteOrAdd
           
protected  java.lang.String pageToLoginTo
           
protected  java.lang.String pageToRedirectToWhenLoginError
           
protected  int pageWidth
           
protected static int pageWidthDefault
           
protected  int percentQuestion
           
protected  boolean printErrorMessagesInline
           
static java.lang.String QUESTION_INFO_CACHE_STRING
           
protected  java.util.Vector questionsAndInfo
           
protected  boolean rememberPageUserIsOn
           
protected  java.lang.String repeatedMeasureDbField
           
protected  java.lang.Number repeatedMeasureValueNumber
           
protected  java.lang.String repeatedMeasureValueString
           
protected  boolean retrieveValuesFromDB
           
protected  boolean showDeleteButton
           
protected  boolean showSubmitButton
          UI Design/Cosmetic Options
protected  boolean showSubmitButtonOnlyIfNoJavaScript
           
protected  boolean showUserErrorMessage
           
protected  boolean skippedBody
           
protected  java.lang.String submitImage
           
protected  java.lang.String submitImageDown
           
protected  java.lang.String submitImageRollover
           
protected  java.lang.String table
           
protected  java.lang.String tableToVerifyLoginTo
           
protected  boolean userHasSetRetrieveValuesFromDB
           
protected  boolean userHasSetShowDeleteButton
           
protected  java.lang.String userIDField
           
protected  java.lang.String userIDValue
           
protected  java.lang.String where
           
protected  boolean whereWasSetByUser
           
 
Fields inherited from class cmu.survey.jsp.tags.DatabaseConnection
databaseConnectionString, databaseType, MS_ACCESS, MYSQL, ODBC, out, session, theConnect, theRequest
 
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
Survey()
           
 
Method Summary
 void addQuestionInfoToHistory(QuestionInfo questionInfo)
           
protected  void addToWhereForAuxillaryFeatureQuestion(HiddenQuestion q)
          Change parameters for the where and for what data to pull from the databases
static java.lang.String cleanStringValueForApostrophesOnly(java.lang.String sqlString)
          We clean this string by clearing out all values that need to be escaped out.
protected  int doDataStuff()
          Does: (a) Check whether the user's logged in (b) Log in the user if not logged in (and if so, go to the next page) (c) Save data to the database if the user submitted data (and if so, go to the next page) (d) Initialize the database for loading answers, etc.
 int doEndTag()
          This function closes the connection when the ending tag is encountered
 int doStartTag()
          This function opens a connection to the requested database when the tag is first encountered
protected  java.util.Vector<Question> getAuxillaryFeatureQuestions()
          This initialized special features after logging in, but before doing questions.
 java.lang.String getBackgroundColor1()
           
 java.lang.String getBackgroundColor2()
           
 java.lang.Object getCachedDataByPage(java.lang.String key)
           
 java.lang.Object getCachedDataIgnoringPage(java.lang.String key)
           
 java.lang.String getClearBackgroundColor()
           
 boolean getCreateUsersAtLogin()
           
protected  java.lang.String getCurrentPageSaveInfo()
          For saving which page we're on.
protected  java.lang.String getCurrentPageURLFromPageSaveInfo(java.lang.String pageSaveInfo)
          Complements the next method.
protected  DataBitStorage getDataBitStorage()
           
 DataStorage getDataStorage()
           
protected  DataTableModel getDataTable()
          Gets this DataTableModel with getTable() (this page of the survey) and knowing what user ID it is.
 java.lang.String getDeleteImage()
           
 java.lang.String getDeleteImageDown()
           
 java.lang.String getDeleteImageRollover()
           
 java.lang.String getEmailResultsSubjectLine()
           
 java.lang.String getEmailResultsTo()
           
 int getFontSize()
           
 java.lang.String getHeaderBackgroundColor()
           
 boolean getIsLoginPage()
           
 int getLastBackgroundColorAlternation()
          Returns the last alternating background color used -- 0 if we've never used one of the two shades, or 1 or 2, depending upon which shade was useld last.
 QuestionInfo getLastQuestionInHistory()
           
protected  java.lang.String getLoginPageString(java.lang.String attributeName)
          Similar to getSessionPageString()
 boolean getNeverMakeNewRecord()
           
protected  java.lang.String getNextPage()
          Called to check what the next page is.
 java.lang.String getNextPageIfDeleteOrAdd()
           
 javax.servlet.jsp.PageContext getPageContext()
           
 java.lang.String getPageToLoginTo()
           
 java.lang.String getPageToRedirectToWhenLoginError()
           
 int getPageWidth()
           
 int getPercentQuestion()
           
 boolean getPrintErrorMessagesInline()
           
 boolean getRememberPageUserIsOn()
           
 java.lang.String getRepeatedMeasureDbField()
          Deprecated. Use getRepeatedMeasureVariable instead.
 java.lang.String getRepeatedMeasureVariable()
           
 boolean getRetrieveValuesFromDB()
          If you want the form to always be blank, setRetrieveValuesFromDB(false) -- it won't get anything from the database.
protected  LoginInfo getSavedLoginInfo()
           
protected  java.lang.String getSessionPageString(javax.servlet.jsp.PageContext pageContext, java.lang.String attributeName)
          Similar to getLoginPageString(java.lang.String) May be overridden by subclasses who have a different concept of what this page is, e.g.
 java.lang.Object getSessionVariableByPage(java.lang.String attributeName)
           
 java.lang.Object getSessionVariableFromLoginPage(java.lang.String attributeName)
           
 boolean getShowAMessageAboutSubmission()
           
 boolean getShowDeleteButton()
           
 boolean getShowSubmitButton()
           
 boolean getShowSubmitButtonOnlyIfNoJavaScript()
           
 java.lang.String getSubmitButtonText()
           
 java.lang.String getSubmitImage()
           
 java.lang.String getSubmitImageDown()
           
 java.lang.String getSubmitImageRollover()
           
 java.lang.String getTable()
           
protected  TableStorage getTableStorage()
           
 java.lang.String getTableToVerifyLoginTo()
           
 boolean getTimeResponses()
           
 java.lang.String getUserIDField()
           
 java.lang.String getWhere()
           
protected  boolean goToNextPage()
           
 boolean isIgnoreWrongTechniqueError()
           
 boolean isShowUserErrorMessages()
           
protected  boolean isUserIDValueANumber()
           
protected  boolean makeAutomaticLoginInfo()
          When you want to log in users without having them put in any information on the login page, call this.
 void reinit()
           
 void saveErrorInfo(java.lang.String message)
           
 void saveErrorInfo(java.lang.String message, java.lang.Throwable exception)
           
protected  void saveLoginInfo(LoginInfo loginInfo)
           
 void setBackgroundColor1(java.lang.String color)
           
 void setBackgroundColor2(java.lang.String color)
           
 void setCachedDataByPage(java.lang.String key, java.lang.Object value)
           
 void setCachedDataIgnoringPage(java.lang.String key, java.lang.Object value)
           
 void setClearBackgroundColor(java.lang.String color)
           
 void setCountTimesVisitingPageField(java.lang.String fieldToCountIn)
          Count the number of times a user visits this page.
 void setCreateUsersAtLogin(boolean bool)
          Create a user if they try to log in and they don't have an account.
 void setDeleteImage(java.lang.String deleteImageName)
          Choose the image to put in place of the delete button.
 void setDeleteImageDown(java.lang.String deleteImageDownName)
           
 void setDeleteImageRollover(java.lang.String deleteImageRolloverName)
           
 void setEmailResultsSubjectLine(java.lang.String subj)
          The subject line for the email with the results of this survey.
 void setEmailResultsTo(java.lang.String emailAddress)
          Send the results of this survey to an email address.
 void setHeaderBackgroundColor(java.lang.String color)
           
 void setIgnoreWrongTechniqueError(boolean ignoreWrongTechniqueError)
           
 void setIsLoginPage(boolean thisPageIsALogin)
          If users need to log in to use your survey, you need a login page, with userid and password as Questions.
 void setLastBackgroundColorAlternation(int lastBackgroundColorAlternation)
           
 void setNeverMakeNewRecord(boolean updateDatabase)
          Never insert a new record into the database -- only do UPDATEs on it.
 void setNextPage(java.lang.String nextPageInSurvey)
          The page to follow this one after submission.
 void setNextPageIfDeleteOrAdd(java.lang.String string)
          Go on to this page next after the current page is completed and submitted, if there was a delete of a record or an add of a record.
 void setPageToLoginTo(java.lang.String pageToRedirectToWhenUserIsNotLoggedIn)
          If you want users to log in, but this is not the login page, put the URL to the login page here -- when they're not logged in, it'll forward them to the login page here, and after they log in, return back to this page.
 void setPageToRedirectToWhenLoginError(java.lang.String pageToRedirectToWhenLoginError)
           
 void setPageWidth(int width)
           
 void setPercentQuestion(int percentOfWidthForQuestion)
           
 void setPrintErrorMessagesInline(boolean b)
           
 void setRememberPageUserIsOn(boolean rememberPage)
          [not completely implemented yet]
Save the page user is currently on in case user leaves survey and comes back later.
 void setRepeatedMeasureDbField(java.lang.String string)
          Deprecated.  
 void setRepeatedMeasureNumber(int i)
           
 void setRepeatedMeasureValue(int i)
          The number that will be saved into the repeatedMeasureDBField.
 void setRepeatedMeasureValue(java.lang.Number i)
           
 void setRepeatedMeasureValue(java.lang.String value)
          The number that will be saved into the repeatedMeasureDBField.
 void setRepeatedMeasureVariable(java.lang.String string)
          The name of the field in the database to save the repeated measure variable.
 void setRetrieveValuesFromDB(boolean retrieveBoolean)
           
 void setSessionVariableFromLoginPage(java.lang.String attributeName, java.lang.Object value)
           
 void setShowAMessageAboutSubmission(boolean showTheOutputGenericUpdateGenerates)
           
 void setShowDeleteButton(boolean showADeleteButtonAtBottom)
          Allows the user to delete records by clicking a delete button at the bottom of the form.
 void setShowSubmitButton(boolean showButtonAtBottom)
          Show a submit button at the bottom of the form.
 void setShowSubmitButtonOnlyIfNoJavaScript(boolean showButtonAtBottom)
          Show a submit button at the bottom of the form only if the browser does not have JavaScript.
 void setShowUserErrorMessages(boolean showUserErrorMessage)
           
 void setSubmitButtonText(java.lang.String submitText)
           
 void setSubmitImage(java.lang.String submitImageName)
          Choose the image to put in place of the submit button.
 void setSubmitImageDown(java.lang.String submitImageDownName)
          Set the image for a mouse click down on the submit button.
 void setSubmitImageRollover(java.lang.String submitImageRolloverName)
          Set the image for a rollover for the submit button.
 void setTable(java.lang.String tableName)
          The table is the table in the SQL database that should be used for loading and saving data.
 void setTableToVerifyLoginTo(java.lang.String tableWithLogins)
          The table with userids/passwords.
 void setTimeResponses(boolean timeResponsesBoolean)
          Whether to time the user on how long it takes them to answer each question and the page.
 void setUserIDField(java.lang.String userID)
           
 void setWhere(java.lang.String newWhere)
          The "where" goes into the query for the table whenever it is loaded/saved.
 void showAMessage(java.lang.String message)
           
 
Methods inherited from class cmu.survey.jsp.tags.DatabaseConnection
checkSQLFieldValid, cleanString, cleanStringBetter, cleanStringThatShouldHaveBeenClean, close, doCatch, doConnection, doFinally, finalize, getConnect, getDatabaseConnectionFrom, getDatabaseName, getDatabaseProgramName, getDatabaseType, getDebuggingInfo, getHelpURL, getLastExceptionThrown, getMySqlDatabaseHost, getMySqlDatabaseName, getMySqlDatabasePassword, getMySqlDatabaseUser, getSession, getThisFolderURL, getThisFullURL, getURLFileName, initializeAtStartTag, isOpen, parseAndCleanNumberStringThatShouldHaveBeenClean, parseAndCleanNumberStringThatShouldHaveBeenCleanStatic, saveBugMessage, saveBugMessage, saveNotificationMessage, saveNotificationMessage, setDatabaseName, setHttpServletRequest, setLastExceptionThrownToNull, setPageContext, setSendErrorMessages
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

protected java.lang.String table

debug

protected static final boolean debug
See Also:
Constant Field Values

retrieveValuesFromDB

protected boolean retrieveValuesFromDB

userHasSetRetrieveValuesFromDB

protected boolean userHasSetRetrieveValuesFromDB

neverMakeNewRecord

protected boolean neverMakeNewRecord

where

protected java.lang.String where

whereWasSetByUser

protected boolean whereWasSetByUser

ignoreWrongTechniqueError

protected boolean ignoreWrongTechniqueError

isLoginPage

protected boolean isLoginPage

createUsersAtLogin

protected boolean createUsersAtLogin

tableToVerifyLoginTo

protected java.lang.String tableToVerifyLoginTo

pageToLoginTo

protected java.lang.String pageToLoginTo

pageToRedirectToWhenLoginError

protected java.lang.String pageToRedirectToWhenLoginError

userIDField

protected java.lang.String userIDField

userIDValue

protected java.lang.String userIDValue

repeatedMeasureDbField

protected java.lang.String repeatedMeasureDbField

repeatedMeasureValueNumber

protected java.lang.Number repeatedMeasureValueNumber

repeatedMeasureValueString

protected java.lang.String repeatedMeasureValueString

showUserErrorMessage

protected boolean showUserErrorMessage

HeaderBackgroundColorDefault

public static final java.lang.String HeaderBackgroundColorDefault
See Also:
Constant Field Values

BackgroundColor1Default

public static final java.lang.String BackgroundColor1Default
See Also:
Constant Field Values

BackgroundColor2Default

public static final java.lang.String BackgroundColor2Default
See Also:
Constant Field Values

clearBackgroundColorDefault

public static java.lang.String clearBackgroundColorDefault

countTimesVisitingPageField

protected java.lang.String countTimesVisitingPageField
See Also:
setCountTimesVisitingPageField(java.lang.String)

emailResultsTo

protected java.lang.String emailResultsTo

emailResultsSubjectLine

protected java.lang.String emailResultsSubjectLine

nextPage

protected java.lang.String nextPage

nextPageIfDeleteOrAdd

protected java.lang.String nextPageIfDeleteOrAdd

rememberPageUserIsOn

protected boolean rememberPageUserIsOn

skippedBody

protected boolean skippedBody

showSubmitButton

protected boolean showSubmitButton
UI Design/Cosmetic Options


showDeleteButton

protected boolean showDeleteButton

userHasSetShowDeleteButton

protected boolean userHasSetShowDeleteButton

submitImage

protected java.lang.String submitImage

submitImageRollover

protected java.lang.String submitImageRollover

submitImageDown

protected java.lang.String submitImageDown

deleteImage

protected java.lang.String deleteImage

deleteImageRollover

protected java.lang.String deleteImageRollover

deleteImageDown

protected java.lang.String deleteImageDown

questionsAndInfo

protected java.util.Vector questionsAndInfo

QUESTION_INFO_CACHE_STRING

public static final java.lang.String QUESTION_INFO_CACHE_STRING
See Also:
Constant Field Values

percentQuestion

protected int percentQuestion

fontSizeDefault

protected static int fontSizeDefault

fontSize

protected int fontSize

pageWidthDefault

protected static int pageWidthDefault

pageWidth

protected int pageWidth

showSubmitButtonOnlyIfNoJavaScript

protected boolean showSubmitButtonOnlyIfNoJavaScript

databaseQuery

protected DatabaseQuery databaseQuery

dataStorage

protected DataStorage dataStorage

printErrorMessagesInline

protected boolean printErrorMessagesInline
Constructor Detail

Survey

public Survey()
Method Detail

getTable

public java.lang.String getTable()
See Also:
setTable(String tableName)

setTable

public void setTable(java.lang.String tableName)
The table is the table in the SQL database that should be used for loading and saving data. All Questions in the Survey will use this table.


getWhere

public java.lang.String getWhere()
See Also:
setWhere(java.lang.String)

setWhere

public void setWhere(java.lang.String newWhere)
The "where" goes into the query for the table whenever it is loaded/saved. For example, if you want to make this particular form/survey access only Aaron's data, you could set UserID="Aaron" -- assuming that there's a column in the database called "UserID" and one in the list titled "Aaron".


getRetrieveValuesFromDB

public boolean getRetrieveValuesFromDB()
If you want the form to always be blank, setRetrieveValuesFromDB(false) -- it won't get anything from the database.
In other words: By default, when a user has logged in, they see their previous answers in the database. If you want them to not see their previous answers (for privacy reasons) setRetrieveValuesFromDB(false). Default: true


setRetrieveValuesFromDB

public void setRetrieveValuesFromDB(boolean retrieveBoolean)

getTimeResponses

public boolean getTimeResponses()
See Also:
setTimeResponses(boolean)

setCountTimesVisitingPageField

public void setCountTimesVisitingPageField(java.lang.String fieldToCountIn)
Count the number of times a user visits this page. This is useful when you want to know if users are doing a page on a survey multiple times. So, a '1' in this field means the user saw it and sumbitted only once.
This feature will only work when users are using Netscape/Mozilla. IE caches the pages and thus it's impossible to tell.
<survey:survey ... countTimesVisitingPageField="fieldInDatabase" ...>
</survey:survey>


setEmailResultsTo

public void setEmailResultsTo(java.lang.String emailAddress)
Send the results of this survey to an email address.
<survey:survey ... emailResultsTo="email@email.com" ...>
</survey:survey>


getEmailResultsTo

public java.lang.String getEmailResultsTo()

isIgnoreWrongTechniqueError

public boolean isIgnoreWrongTechniqueError()
Returns:
Returns the ignoreWrongTechniqueError.

setIgnoreWrongTechniqueError

public void setIgnoreWrongTechniqueError(boolean ignoreWrongTechniqueError)
Parameters:
ignoreWrongTechniqueError - The ignoreWrongTechniqueError to set.

setEmailResultsSubjectLine

public void setEmailResultsSubjectLine(java.lang.String subj)
The subject line for the email with the results of this survey. (Only used if emailResultsTo is set)
<survey:survey ... emailResultsTo="email@email.com" emailResultsSubjectLine="Big Car Survey" ...>
</survey:survey>


getEmailResultsSubjectLine

public java.lang.String getEmailResultsSubjectLine()

setTimeResponses

public void setTimeResponses(boolean timeResponsesBoolean)
Whether to time the user on how long it takes them to answer each question and the page.
Default: false

If timing:

The time spent on the page before hitting submit will be put into the database table getTable() with a field titled "number_timeSpent"
The field "number"+timeResponsesAppendix (by default, this would be "number_timeSpent" must exist in your table before you use this method! Otherwise it will throw various exceptions.

The time spent on the page before answering any Question will be put into Question.getField()+timeResponsesAppendix
This field must exist in the table, otherwise SQL exceptions will be thrown when the form is submitted.


getNeverMakeNewRecord

public boolean getNeverMakeNewRecord()

setNeverMakeNewRecord

public void setNeverMakeNewRecord(boolean updateDatabase)
Never insert a new record into the database -- only do UPDATEs on it. Default: false Example: This is used in one specific spot: when there is a table, such as a table with a set of preferences, which has only 1 row, and no primary key -- this means that the we don't need a WHERE clause because we're always updating the same row, which always exists -- and we never want to create any more rows. When it is used, it assumes that all rows are roughly the same -- so that it will do updates on ALL rows -- so all rows will become the same shortly after. It'll also only retrieve data from the first row of the set.


getRepeatedMeasureDbField

public java.lang.String getRepeatedMeasureDbField()
Deprecated. Use getRepeatedMeasureVariable instead.

Returns:
See Also:
setRepeatedMeasureDbField(String)

getRepeatedMeasureVariable

public java.lang.String getRepeatedMeasureVariable()
Returns:
See Also:
setRepeatedMeasureVariable(String)

setRepeatedMeasureDbField

public void setRepeatedMeasureDbField(java.lang.String string)
Deprecated. 

This method is obsolete -- use setRepeatedMeasureVariable instead.

See Also:
setRepeatedMeasureVariable(String)

setRepeatedMeasureVariable

public void setRepeatedMeasureVariable(java.lang.String string)
The name of the field in the database to save the repeated measure variable.

Setting this turns on the repeated measures. A repeated measure happens two ways:
  1. If you don't set repeatedMeasureNumber:
    Each time the user hits the page, it will create a new row in the database. The data will be fresh and clean each time. So, if you want users to fill out a survey many times in a row, create a variable in your Answers table to store the visit number, and then set this to that name.
  2. If you do set repeatedMeasureNumber to a different number on each page:
    It will create a different row for each page that has a specific repeatedMeasureNumber. For example, if you want 3 rows for 3 different pages, page1.jsp, page2.jsp, and page3.jsp, you can create a variable named "repeatedMeasure" in your Answers table to store it, and then:
    1. on each page in the survey tag, set 'repeatedMeasureDbField="repeatedMeasure"'
    2. on page1.jsp, in the survey tag, set 'repeatedMeasureNumber="1"', on page2.jsp, in the survey tag, set 'repeatedMeasureNumber="2"', etc.

Requirements: - The database must store this as a number, not a string.
If you don't also set repeatedMeasureNumber to say the current repeated measure on this page, it'll automatically start at 1 and increment it each time the user hits the page after a save.

See Also:
setRepeatedMeasureNumber(int)

setRepeatedMeasureNumber

public void setRepeatedMeasureNumber(int i)
Parameters:
i -
See Also:
setRepeatedMeasureDbField(String)

setRepeatedMeasureValue

public void setRepeatedMeasureValue(java.lang.Number i)

setRepeatedMeasureValue

public void setRepeatedMeasureValue(int i)
The number that will be saved into the repeatedMeasureDBField. See setRepeatedMeasureDbField(String) for details and an example.

Parameters:
i -
See Also:
setRepeatedMeasureDbField(String)

setRepeatedMeasureValue

public void setRepeatedMeasureValue(java.lang.String value)
The number that will be saved into the repeatedMeasureDBField. See setRepeatedMeasureDbField(String) for details and an example.

Parameters:
i -
See Also:
setRepeatedMeasureDbField(String)

getShowSubmitButton

public boolean getShowSubmitButton()

setShowSubmitButton

public void setShowSubmitButton(boolean showButtonAtBottom)
Show a submit button at the bottom of the form.
Default: true


getShowSubmitButtonOnlyIfNoJavaScript

public boolean getShowSubmitButtonOnlyIfNoJavaScript()

setShowSubmitButtonOnlyIfNoJavaScript

public void setShowSubmitButtonOnlyIfNoJavaScript(boolean showButtonAtBottom)
Show a submit button at the bottom of the form only if the browser does not have JavaScript.
Default: false

For example, suppose you are writing a survey that will automatically flip to the next page when you click on any answer. (You can do this with Question.setAutoSubmitWhenFinishedWithThisQuestion(true)).
You would not need the "submit" button to show, since it's automatically submitted. However, if the browser has no JavaScript, this function will not work -- the auto-submit won't happen. So, the user would click on the radio button and then have to manually click on a submit button -- hence, showing it when there is no JavaScript in the browser.


getShowDeleteButton

public boolean getShowDeleteButton()

setShowDeleteButton

public void setShowDeleteButton(boolean showADeleteButtonAtBottom)
Allows the user to delete records by clicking a delete button at the bottom of the form.


getSubmitImage

public java.lang.String getSubmitImage()

setSubmitImage

public void setSubmitImage(java.lang.String submitImageName)
Choose the image to put in place of the submit button.


getSubmitImageRollover

public java.lang.String getSubmitImageRollover()

setSubmitImageRollover

public void setSubmitImageRollover(java.lang.String submitImageRolloverName)
Set the image for a rollover for the submit button. You must also setSubmitImage(java.lang.String)


getSubmitImageDown

public java.lang.String getSubmitImageDown()

setSubmitImageDown

public void setSubmitImageDown(java.lang.String submitImageDownName)
Set the image for a mouse click down on the submit button. You must also setSubmitImage(java.lang.String)


getDeleteImage

public java.lang.String getDeleteImage()

setDeleteImage

public void setDeleteImage(java.lang.String deleteImageName)
Choose the image to put in place of the delete button.


getDeleteImageRollover

public java.lang.String getDeleteImageRollover()

setDeleteImageRollover

public void setDeleteImageRollover(java.lang.String deleteImageRolloverName)

getDeleteImageDown

public java.lang.String getDeleteImageDown()

setDeleteImageDown

public void setDeleteImageDown(java.lang.String deleteImageDownName)

getPageWidth

public int getPageWidth()

setPageWidth

public void setPageWidth(int width)

getPercentQuestion

public int getPercentQuestion()

setPercentQuestion

public void setPercentQuestion(int percentOfWidthForQuestion)

getFontSize

public int getFontSize()

getHeaderBackgroundColor

public java.lang.String getHeaderBackgroundColor()

getBackgroundColor1

public java.lang.String getBackgroundColor1()

getBackgroundColor2

public java.lang.String getBackgroundColor2()

getClearBackgroundColor

public java.lang.String getClearBackgroundColor()

setHeaderBackgroundColor

public void setHeaderBackgroundColor(java.lang.String color)

setBackgroundColor1

public void setBackgroundColor1(java.lang.String color)

setBackgroundColor2

public void setBackgroundColor2(java.lang.String color)

setClearBackgroundColor

public void setClearBackgroundColor(java.lang.String color)

getLastBackgroundColorAlternation

public int getLastBackgroundColorAlternation()
Returns the last alternating background color used -- 0 if we've never used one of the two shades, or 1 or 2, depending upon which shade was useld last. Use this in conjunction with getBackgroundColor1() and getBackgroundColor2() to see what color we should do next.

Returns:
the last alternating background color used

setLastBackgroundColorAlternation

public void setLastBackgroundColorAlternation(int lastBackgroundColorAlternation)
Parameters:
lastBackgroundColorAlternation - The lastBackgroundColorAlternation to set.

getSubmitButtonText

public java.lang.String getSubmitButtonText()

setSubmitButtonText

public void setSubmitButtonText(java.lang.String submitText)

setShowAMessageAboutSubmission

public void setShowAMessageAboutSubmission(boolean showTheOutputGenericUpdateGenerates)

getShowAMessageAboutSubmission

public boolean getShowAMessageAboutSubmission()

getPrintErrorMessagesInline

public boolean getPrintErrorMessagesInline()
Returns:

setPrintErrorMessagesInline

public void setPrintErrorMessagesInline(boolean b)
Parameters:
b -

isShowUserErrorMessages

public boolean isShowUserErrorMessages()
Returns:
Returns the showErrorMessage.

setShowUserErrorMessages

public void setShowUserErrorMessages(boolean showUserErrorMessage)
Parameters:
showErrorMessage - The showErrorMessage to set.

getPageContext

public javax.servlet.jsp.PageContext getPageContext()

getDataStorage

public DataStorage getDataStorage()

getIsLoginPage

public boolean getIsLoginPage()
See Also:
setIsLoginPage(boolean)

setIsLoginPage

public void setIsLoginPage(boolean thisPageIsALogin)
If users need to log in to use your survey, you need a login page, with userid and password as Questions. If it is a login page, the Questions will all need to match the answers in the database for the user to authenticate. If the data matches, the users is logged in and the login info is saved for later usage (so the user only needs to log in once).

See Also:
setTableToVerifyLoginTo(String tableWithLogins), setPageToLoginTo(String pageToRedirectToWhenUserIsNotLoggedIn)

getTableToVerifyLoginTo

public java.lang.String getTableToVerifyLoginTo()

setTableToVerifyLoginTo

public void setTableToVerifyLoginTo(java.lang.String tableWithLogins)
The table with userids/passwords.
Default: getTable()


getPageToLoginTo

public java.lang.String getPageToLoginTo()

setUserIDField

public void setUserIDField(java.lang.String userID)

getUserIDField

public java.lang.String getUserIDField()

setPageToLoginTo

public void setPageToLoginTo(java.lang.String pageToRedirectToWhenUserIsNotLoggedIn)
If you want users to log in, but this is not the login page, put the URL to the login page here -- when they're not logged in, it'll forward them to the login page here, and after they log in, return back to this page. (It will not currently pass the parameters originally passed back to this page -- this is a bug that should be fixed).


getPageToRedirectToWhenLoginError

public java.lang.String getPageToRedirectToWhenLoginError()
Returns:
Returns the pageToRedirectToWhenLoginError.

setPageToRedirectToWhenLoginError

public void setPageToRedirectToWhenLoginError(java.lang.String pageToRedirectToWhenLoginError)
Parameters:
pageToRedirectToWhenLoginError - The pageToRedirectToWhenLoginError to set.

getNextPage

protected java.lang.String getNextPage()
Called to check what the next page is. Can be overridden by subclasses. When subclasess return a page, it will use that as the next page to go to, after this page is finished. This may return null. This will be called once before the user has logged in. At that time, it's not necessary to return the right thing -- it can return null. When it it called after the user has logged in (i.e. getSavedLoginInfo()!=null if user has logged in), it means that we're about to transition to the new page, so this should not return null unless it is intended to stay on the same page. Return null at any time to stay on the same page.

Returns:

setNextPage

public void setNextPage(java.lang.String nextPageInSurvey)
The page to follow this one after submission. The survey will go on to this page next after the current page is completed and submitted. Note that if a page is passed to this page as a parameter (page.jsp?redir=otherPage), that page will override this nextPage. When a page is passed there, it indicates that this page is being used as a login page, and that after logging in, it should redirect to the other page. (For example, if a user bookmarks survey3.jsp instead of login.jsp and then later comes back to survey3.jsp, it'll jump to login.jsp and after login redirect to survey3.jsp after the user successfully logs in). This can be overridden to make the next page go somewhere else.


getNextPageIfDeleteOrAdd

public java.lang.String getNextPageIfDeleteOrAdd()
See Also:
setNextPageIfDeleteOrAdd(String)

setNextPageIfDeleteOrAdd

public void setNextPageIfDeleteOrAdd(java.lang.String string)
Go on to this page next after the current page is completed and submitted, if there was a delete of a record or an add of a record. Note that if a page is passed to this page as a parameter (page.jsp?redir=otherPage), the other page will override the nextPage. When a page is passed there, it indicates that this page is being used as a login page, and that after logging in, it should redirect to the other page. (For example, if a user bookmarks survey.jsp instead of login.jsp first, it'll first go to login.jsp and then redirect to survey.jsp after the user successfully logs in).


getRememberPageUserIsOn

public boolean getRememberPageUserIsOn()
Returns:
See Also:
setRememberPageUserIsOn(boolean)

setRememberPageUserIsOn

public void setRememberPageUserIsOn(boolean rememberPage)
[not completely implemented yet]
Save the page user is currently on in case user leaves survey and comes back later.
Requirements:
- you must use the standard login method (i.e. also set 'userIDField', as in the Users table, in the demos)
- must have a column in the login table called "CurrentPage"
If you set this on a non-login page, when the page loads, it will set that "CurrentPage" column to the name of the current page.
If you set this on the login page, when the user logs it it will go to the last page that was saved. If all pages have rememberPageUserIsOn set to true, this means that the user will go to the last page that they were on before leaving the site.

Parameters:
b -

getCreateUsersAtLogin

public boolean getCreateUsersAtLogin()

setCreateUsersAtLogin

public void setCreateUsersAtLogin(boolean bool)
Create a user if they try to log in and they don't have an account. Example: A site for controlling subscriptions -- if a user types in their email and doesn't have an account, you'd want to create it immediately. (To save their preferences).


cleanStringValueForApostrophesOnly

public static final java.lang.String cleanStringValueForApostrophesOnly(java.lang.String sqlString)
We clean this string by clearing out all values that need to be escaped out.
This method should be used on SQL strings that are to be used in SQL, such as field, table, and database names. For example, if the desired SQL String is:
    "SELECT * FROM "+TABLE-NAME+" WHERE "+FIELD+"='"+VALUE+"'"
make sure to do:
    "SELECT * FROM "+cleanString(TABLE-NAME)+" WHERE "+cleanString(FIELD)+"='"+cleanStringValue(VALUE)+"'"

IMPORTANT NOTE: After using this, make sure to use apostrophes around your VALUE field, not quotes! If you use " the user can still hack in using " to end the sentence. Only ' and \ are escaped.


setCachedDataByPage

public void setCachedDataByPage(java.lang.String key,
                                java.lang.Object value)
Specified by:
setCachedDataByPage in interface SurveyDataCache

setCachedDataIgnoringPage

public void setCachedDataIgnoringPage(java.lang.String key,
                                      java.lang.Object value)
Specified by:
setCachedDataIgnoringPage in interface SurveyDataCache

getCachedDataByPage

public java.lang.Object getCachedDataByPage(java.lang.String key)
Specified by:
getCachedDataByPage in interface SurveyDataCache

getCachedDataIgnoringPage

public java.lang.Object getCachedDataIgnoringPage(java.lang.String key)
Specified by:
getCachedDataIgnoringPage in interface SurveyDataCache

getSessionPageString

protected java.lang.String getSessionPageString(javax.servlet.jsp.PageContext pageContext,
                                                java.lang.String attributeName)
Similar to getLoginPageString(java.lang.String) May be overridden by subclasses who have a different concept of what this page is, e.g. SurveyAuto.


setSessionVariableFromLoginPage

public void setSessionVariableFromLoginPage(java.lang.String attributeName,
                                            java.lang.Object value)

getSessionVariableFromLoginPage

public java.lang.Object getSessionVariableFromLoginPage(java.lang.String attributeName)

getSessionVariableByPage

public java.lang.Object getSessionVariableByPage(java.lang.String attributeName)

getLoginPageString

protected java.lang.String getLoginPageString(java.lang.String attributeName)
Similar to getSessionPageString()


getTableStorage

protected TableStorage getTableStorage()

getDataBitStorage

protected DataBitStorage getDataBitStorage()

getDataTable

protected DataTableModel getDataTable()
Gets this DataTableModel with getTable() (this page of the survey) and knowing what user ID it is. You do NOT need to close this when you are done. It will be closed automatically. Do *NOT* use save this or use this in a thread, because it is cached across these calls. Since it's cached (a) it will be closed automatically, and (b) it will be cleaned up the next time someone calls getDataTable(), which could get in the middle of your usage if you cache it separately.

Parameters:
answersTable -
Returns:

addToWhereForAuxillaryFeatureQuestion

protected void addToWhereForAuxillaryFeatureQuestion(HiddenQuestion q)
Change parameters for the where and for what data to pull from the databases


getAuxillaryFeatureQuestions

protected java.util.Vector<Question> getAuxillaryFeatureQuestions()
This initialized special features after logging in, but before doing questions. It returns questions to represent those special features. Currently, the special features are only:
  1. User IDs and logging in
  2. Repeated Measures
Thes questions should then:
  1. if they are keys: be added to the WHERE clause for the database queries
  2. get printed in printStartForm()
Subclasses should definitely call this first, and then add their options to it. They may want to set repeated measure options before letting this be called.

Returns:
a vector of HiddenQuestion

isUserIDValueANumber

protected boolean isUserIDValueANumber()

saveLoginInfo

protected void saveLoginInfo(LoginInfo loginInfo)

getSavedLoginInfo

protected LoginInfo getSavedLoginInfo()

makeAutomaticLoginInfo

protected boolean makeAutomaticLoginInfo()
When you want to log in users without having them put in any information on the login page, call this. It will automatically generate the next UserID.

Returns:

goToNextPage

protected boolean goToNextPage()

getCurrentPageURLFromPageSaveInfo

protected java.lang.String getCurrentPageURLFromPageSaveInfo(java.lang.String pageSaveInfo)
Complements the next method. Is basically the same -- should return the

Parameters:
pageSaveInfo - the info saved, as per getCurrentPageSaveInfo().
Returns:
the partial URL for the next page.

getCurrentPageSaveInfo

protected java.lang.String getCurrentPageSaveInfo()
For saving which page we're on. This method may be overridden to save different information about what page we should be on (and is overridden in SurveyAuto) This method is assumed to send back database-clean information -- no apostrophes, no backslashes, etc.


showAMessage

public void showAMessage(java.lang.String message)

saveErrorInfo

public void saveErrorInfo(java.lang.String message)

saveErrorInfo

public void saveErrorInfo(java.lang.String message,
                          java.lang.Throwable exception)

addQuestionInfoToHistory

public void addQuestionInfoToHistory(QuestionInfo questionInfo)

getLastQuestionInHistory

public QuestionInfo getLastQuestionInHistory()

doDataStuff

protected int doDataStuff()
Does: (a) Check whether the user's logged in (b) Log in the user if not logged in (and if so, go to the next page) (c) Save data to the database if the user submitted data (and if so, go to the next page) (d) Initialize the database for loading answers, etc. (c) more...?

Returns:
whether it was handled. It won't be handled if the questions were not available yet. For example, the questions might not be cached if the user wasn't logged in, which will make this not work.

doStartTag

public int doStartTag()
Description copied from class: DatabaseConnection
This function opens a connection to the requested database when the tag is first encountered

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class DatabaseConnection

doEndTag

public int doEndTag()
Description copied from class: DatabaseConnection
This function closes the connection when the ending tag is encountered

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class DatabaseConnection

reinit

public void reinit()
Overrides:
reinit in class DatabaseConnection