cmu.survey.jsp.tags
Class QuestionWithChoices

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by cmu.survey.jsp.tags.TagSupportAndMore
          extended by cmu.survey.jsp.tags.QuestionTagStub
              extended by cmu.survey.jsp.tags.Question
                  extended by cmu.survey.jsp.tags.QuestionWithVariable
                      extended by cmu.survey.jsp.tags.QuestionWithChoices
All Implemented Interfaces:
HasErrorInfo, HasErrorInfoAndSaves, QuestionTag, java.io.Serializable, java.lang.Cloneable, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.Tag, javax.servlet.jsp.tagext.TryCatchFinally
Direct Known Subclasses:
CheckboxList, DropDownQuestion, HorizontalRadioHeaders, RadioButtonQuestion

public abstract class QuestionWithChoices
extends QuestionWithVariable

See Also:
Serialized Form

Field Summary
protected  boolean saveTheTitle
           
 
Fields inherited from class cmu.survey.jsp.tags.QuestionWithVariable
dbField, FieldTypeIsKey, FieldTypeIsNumeric, FieldTypes, type
 
Fields inherited from class cmu.survey.jsp.tags.Question
blankImageLocation, endQuestion, helpText, imageDirectory, question
 
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
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
QuestionWithChoices()
           
 
Method Summary
protected  java.util.Vector getCachedAnswerPair()
           
 boolean getCacheRandomizeAnswerOrder()
           
 java.lang.String getChoicesField()
           
 java.lang.Integer getChoicesQuestionID()
           
 java.lang.String getChoicesSQLWhere()
           
 QuestionChoicesWithIDField getQuestionChoicesWithIDField()
           
 boolean getRandomizeAnswerOrder()
           
 boolean getStartIndexesAtZero()
           
 QuestionChoices.VectorPair getTupleFromChoices()
          This method is new -- getTupleOfChoicesAndIDs is old and almost obsolete.
 boolean isChoicesTableStandardFormat()
           
 void reinit()
           
protected  void setCachedAnswerPair(java.util.Vector tuple)
          Randomize the orders of the items in a pair of vectors -- both vectors should be the same size.
 void setCacheRandomizeAnswerOrder(boolean cacheRandomization)
           
 void setChoices(java.lang.String[] newChoices)
           
 void setChoicesField(java.lang.String newValue)
           
 void setChoicesIDField(java.lang.String newValue)
           
 void setChoicesQuestionID(java.lang.Integer string)
           
 void setChoicesSQLWhere(java.lang.String where)
           
 void setChoicesTable(java.lang.String newValue)
           
 void setChoicesTableUsingStandardFormat(java.lang.String theChoicesTable, java.lang.Integer theChoicesQuestionID)
          The standard format is a specific format for the database table for these answers.
 void setRandomizeAnswerOrder(boolean randomize)
           
 void setSaveTheTitle(boolean b)
          By default, the index number of the choice is saved in the table.
 void setStartIndexesAtZero(boolean b)
           
 
Methods inherited from class cmu.survey.jsp.tags.QuestionWithVariable
getAnswer, getDbField, getExtraJavaScripts, getExtraJavaScripts, getFieldAndType, getFieldAndType, getTimeSpentInOnClickOrPressed, getTimeSpentInOnClickOrPressed, getType, hasVariable, isTypeKey, isTypeNumeric, isTypeNumeric, isValidType, printTimeSpentField, saveQuestionInfo, setDbField, setDefaultValue, setType
 
Methods inherited from class cmu.survey.jsp.tags.Question
clone, doEndOfQuestion, doEndOfQuestionNoPrinting, doMiddleOfQuestion, doQuestion, doStartOfQuestion, doStartOfQuestion, getAutoSubmitWhenFinishedWithThisQuestion, getBackgroundColorHTMLText, getDatabaseQuery, getEndQuestion, getExtraErrorInfo, getHelpText, getID, getOtherQuestionInfoToSave, getQuestion, getSupplementalErrorInfo, print, print, printTimeSpentField, setAutoSubmitWhenFinishedWithThisQuestion, setBackgroundColor, setEndQuestion, setHelpText, setID, setNumberOfColumns, setOtherQuestionInfoToSave, setQuestion, setSupplementalErrorInfo
 
Methods inherited from class cmu.survey.jsp.tags.QuestionTagStub
doStartTag, getErrorInfo, getSurvey, initSurvey, saveErrorInfo
 
Methods inherited from class cmu.survey.jsp.tags.TagSupportAndMore
breakDownToArray, convertDayNameToNum, convertDayNumToName, convertDayNumToName, convertMonthNumToName, doCatch, doEndTag, doFinally, formatDateTimeViewable, formatDateTimeViewable, formatDateViewable, formatTimeNoSecondsViewable, formatTimeNoSecondsViewable, formatTimeNoSecondsViewable, getNumDaysInWeek, parseTimeNoSecondsFromViewable, 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
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cmu.survey.jsp.tags.HasErrorInfoAndSaves
saveErrorInfo
 
Methods inherited from interface cmu.survey.jsp.tags.HasErrorInfo
getErrorInfo
 

Field Detail

saveTheTitle

protected boolean saveTheTitle
Constructor Detail

QuestionWithChoices

public QuestionWithChoices()
Method Detail

setChoices

public void setChoices(java.lang.String[] newChoices)

setChoicesTable

public void setChoicesTable(java.lang.String newValue)

getChoicesField

public java.lang.String getChoicesField()

setChoicesField

public void setChoicesField(java.lang.String newValue)

setChoicesIDField

public void setChoicesIDField(java.lang.String newValue)

setChoicesSQLWhere

public void setChoicesSQLWhere(java.lang.String where)

setChoicesTableUsingStandardFormat

public void setChoicesTableUsingStandardFormat(java.lang.String theChoicesTable,
                                               java.lang.Integer theChoicesQuestionID)
The standard format is a specific format for the database table for these answers. (This feature is related to the tag QuestionsFromDatabase, which is not completely implemented yet)


setCacheRandomizeAnswerOrder

public void setCacheRandomizeAnswerOrder(boolean cacheRandomization)

setRandomizeAnswerOrder

public void setRandomizeAnswerOrder(boolean randomize)

getStartIndexesAtZero

public boolean getStartIndexesAtZero()
Returns:

setStartIndexesAtZero

public void setStartIndexesAtZero(boolean b)
Parameters:
b -

setCachedAnswerPair

protected void setCachedAnswerPair(java.util.Vector tuple)
Randomize the orders of the items in a pair of vectors -- both vectors should be the same size. This randomizes the orders of the items in parallel -- i.e. if there's a mapping between one vector to another, it is preserved in the randomization, for example:

Before:

Vector 1 Vector 2
1 a
2 b
3 c
4 d

 

After (for example):

Vector 1 Vector 2
4 d
2 b
1 a
3 c
Returns a vector with two elements: vector1 randomized, and vector2 randomized.


getCachedAnswerPair

protected java.util.Vector getCachedAnswerPair()

getTupleFromChoices

public QuestionChoices.VectorPair getTupleFromChoices()
This method is new -- getTupleOfChoicesAndIDs is old and almost obsolete. Use this instead if possible.


getQuestionChoicesWithIDField

public QuestionChoicesWithIDField getQuestionChoicesWithIDField()

isChoicesTableStandardFormat

public boolean isChoicesTableStandardFormat()
Returns:

getChoicesQuestionID

public java.lang.Integer getChoicesQuestionID()
Returns:

setChoicesQuestionID

public void setChoicesQuestionID(java.lang.Integer string)
Parameters:
string -

getChoicesSQLWhere

public java.lang.String getChoicesSQLWhere()
Returns:

getCacheRandomizeAnswerOrder

public boolean getCacheRandomizeAnswerOrder()
Returns:

getRandomizeAnswerOrder

public boolean getRandomizeAnswerOrder()
Returns:

setSaveTheTitle

public void setSaveTheTitle(boolean b)
By default, the index number of the choice is saved in the table. For example: [User's Selection] --> [value saved in database] Male --> 1 Female --> 2 [No choice picked] --> 0 If saveTheTitle is set to true, the following is done instead: [User's Selection] --> [value saved in database] Male --> 'Male' Female --> 'Female' [No choice picked] --> '' (can be either an empty string or null) or, for example, if the type is a number, [User's Selection] --> [value saved in database] 60 --> 60 84 --> 84 96 --> 96 [No choice picked] --> 0


reinit

public void reinit()
Overrides:
reinit in class QuestionWithVariable