com.arsdigita.formbuilder
Class SimpleQuestionnaire

java.lang.Object
  extended bycom.arsdigita.formbuilder.SimpleQuestionnaire
All Implemented Interfaces:
AttributeMetaDataProvider, PersistentComponentFactory

public class SimpleQuestionnaire
extends Object
implements PersistentComponentFactory, AttributeMetaDataProvider

A simple questionnaire is a list of questions and a submit button. Every question is a label-widget pair (a Bebop Label and a Bebop Widget). The SimpleQuestionnaire is a special case of the PersistentForm and uses such an object internally. The questionnaire offers methods to move questions around and remove questions. I chose not to extend the PersistentForm class since the SimpleQuestionnaire is not an extension of that domain object but rather replaces many of its methods (i.e. add(Component)) with its own special methods (i.e. addQuestion).

Version:
$Id: //core-platform/dev/src/com/arsdigita/formbuilder/SimpleQuestionnaire.java#11 $
Author:
Peter Marklund

Field Summary
static String versionId
           
 
Constructor Summary
SimpleQuestionnaire()
          Default Constructor.
SimpleQuestionnaire(BigDecimal formID)
           
SimpleQuestionnaire(String htmlName, String adminName)
          Construct a new Questionnaire that can be persisted with the save() method.
 
Method Summary
 void addProcessListener(PersistentProcessListener processListener)
           
 void addQuestion(String questionText, PersistentWidget widgetFactory)
          Add a question after the questions already added.
 void addQuestion(String questionText, PersistentWidget widgetFactory, int position)
          Add a question at the given position.
 Component createComponent()
          Returns the Bebop Form representing this questionnaire.
 void delete()
          Delete this questionnaire.
 String getAdminName()
           
 AttributeMetaDataList getAttributeMetaData()
           
 String getDescription()
           
 String getHtmlName()
           
 BigDecimal getID()
           
 AttributeMetaDataList getListenerMetaData()
           
 int getNumberOfQuestions()
           
 Iterator getProcessListeners()
          For convenience I provide the test process listener as default
 PersistentLabel getQuestionLabel(int questionPosition)
           
 PersistentWidget getQuestionWidget(int questionPosition)
           
 String getSubmitLabel()
           
 boolean isNew()
          Indicates if this questionnaire has been saved or not
 boolean listenerDictatesParameterSet()
          If this returns true add links for questions will not be allowed, otherwise they will.
 boolean listenerHasMetaData()
          Returns true if the process listener associated with the quesionnaire implements the AttributeMetaDataProvider interface and has more than zero attribute meta data objects that can be fetched via this interface.
 void moveQuestion(int atPosition, int toPosition)
          Move a question from its current position to a new position.
 void removeQuestion(int position)
          Remove a question at a certain position.
 void save()
           
 void setAdminEnabled(boolean isAdminEnabled)
          Indicates if links should be added to the questionnaire with which the questions can be managed (added, edited and deleted).
 void setAdminName(String adminName)
           
 void setDescription(String description)
           
 void setHtmlName(String htmlName)
          Care has been taken to make this method name JavaBean compiant with the htmlName property
 void setID(BigDecimal id)
           
 void setSubmitLabel(String submitLabel)
          Every simple questionnaire will have a submit button at the bottom.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

SimpleQuestionnaire

public SimpleQuestionnaire()
Default Constructor. Should normally not be used be application developers. Is only here to enable instantiation by FormSectionGenerator


SimpleQuestionnaire

public SimpleQuestionnaire(String htmlName,
                           String adminName)
Construct a new Questionnaire that can be persisted with the save() method.


SimpleQuestionnaire

public SimpleQuestionnaire(BigDecimal formID)
                    throws DataObjectNotFoundException
Method Detail

save

public void save()
Specified by:
save in interface PersistentComponentFactory

isNew

public boolean isNew()
Indicates if this questionnaire has been saved or not

Specified by:
isNew in interface PersistentComponentFactory

delete

public void delete()
Delete this questionnaire. This method will not only delete the Form but also all its contained components.

Specified by:
delete in interface PersistentComponentFactory

createComponent

public Component createComponent()
Returns the Bebop Form representing this questionnaire.

Specified by:
createComponent in interface PersistentComponentFactory

addQuestion

public void addQuestion(String questionText,
                        PersistentWidget widgetFactory)
Add a question after the questions already added.


addQuestion

public void addQuestion(String questionText,
                        PersistentWidget widgetFactory,
                        int position)
Add a question at the given position. Position refers to the order number of the questions and starts with 1.


removeQuestion

public void removeQuestion(int position)
Remove a question at a certain position. Position refers to the order number of the questions and starts with 1.


moveQuestion

public void moveQuestion(int atPosition,
                         int toPosition)
Move a question from its current position to a new position. Position refers to the order number of the questions and starts with 1.


getQuestionLabel

public PersistentLabel getQuestionLabel(int questionPosition)

getQuestionWidget

public PersistentWidget getQuestionWidget(int questionPosition)

getHtmlName

public String getHtmlName()

setHtmlName

public void setHtmlName(String htmlName)
Care has been taken to make this method name JavaBean compiant with the htmlName property


setAdminEnabled

public void setAdminEnabled(boolean isAdminEnabled)
Indicates if links should be added to the questionnaire with which the questions can be managed (added, edited and deleted). Those links are needed in the Form Builder administration pages. Per default those links will not be added.


getNumberOfQuestions

public int getNumberOfQuestions()

setSubmitLabel

public void setSubmitLabel(String submitLabel)
Every simple questionnaire will have a submit button at the bottom. This method sets the label of that submit button


getSubmitLabel

public String getSubmitLabel()

setAdminName

public void setAdminName(String adminName)

getAdminName

public String getAdminName()

setDescription

public void setDescription(String description)

getDescription

public String getDescription()

addProcessListener

public void addProcessListener(PersistentProcessListener processListener)

getProcessListeners

public Iterator getProcessListeners()
For convenience I provide the test process listener as default


setID

public void setID(BigDecimal id)

getID

public BigDecimal getID()
Specified by:
getID in interface PersistentComponentFactory

getAttributeMetaData

public AttributeMetaDataList getAttributeMetaData()
Specified by:
getAttributeMetaData in interface AttributeMetaDataProvider

listenerDictatesParameterSet

public boolean listenerDictatesParameterSet()
If this returns true add links for questions will not be allowed, otherwise they will. For now, if the process listener supplies any attribute metadata at all we assume that this is a strict contract parameter set for the persistent form to follow. We might make it configurable to soften this constraint later on.


listenerHasMetaData

public boolean listenerHasMetaData()
Returns true if the process listener associated with the quesionnaire implements the AttributeMetaDataProvider interface and has more than zero attribute meta data objects that can be fetched via this interface.


getListenerMetaData

public AttributeMetaDataList getListenerMetaData()


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC