Class ChoicesListQuestionType
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.forms.question.types.AbstractStaticFormQuestionType
org.ametys.plugins.forms.question.types.AbstractFormQuestionType
org.ametys.plugins.forms.question.types.ChoicesListQuestionType
- All Implemented Interfaces:
FormQuestionType
,ConfidentialAwareQuestionType
,DescriptibleFormQuestionType
,IllustrableFormQuestionType
,MandatoryAwareFormQuestionType
,MultipleAwareFormQuestionType
,RestrictiveQuestionType
,LogEnabled
,PluginAware
,Configurable
,Serviceable
public class ChoicesListQuestionType
extends AbstractFormQuestionType
implements MultipleAwareFormQuestionType
Class for creating choices list questions
-
Field Summary
Modifier and TypeFieldDescriptionprotected ChoiceSourceTypeExtensionPoint
The choice source type extension pointstatic final String
Constant for the format attributestatic final String
Constant for other option attributestatic final String
Constant for placeholder attribute.static final String
Constant for source type attributestatic final String
Name of checkbox formatStaticEnumerator entrystatic final String
Name of combobox formatStaticEnumerator entrystatic final String
Constant for default titlestatic final String
Id of the default type for formatStaticEnumeratorstatic final String
Label of the other option valuestatic final String
Label of the other option valueFields inherited from class org.ametys.plugins.forms.question.types.AbstractFormQuestionType
_workflowHelper
Fields inherited from class org.ametys.plugins.forms.question.types.AbstractStaticFormQuestionType
_category, _description, _formQuestionModel, _i18nUtils, _iconGlyph, _id, _label, _pluginName, _priority, _scripts, _xslt
Fields inherited from interface org.ametys.plugins.forms.question.types.ConfidentialAwareQuestionType
ATTRIBUTE_CONFIDENTIALITY
Fields inherited from interface org.ametys.plugins.forms.question.types.DescriptibleFormQuestionType
ATTRIBUTE_DESCRIPTION
Fields inherited from interface org.ametys.plugins.forms.question.types.IllustrableFormQuestionType
ATTRIBUTE_PICTURE, ATTRIBUTE_PICTURE_ALTERNATIVE
Fields inherited from interface org.ametys.plugins.forms.question.types.MandatoryAwareFormQuestionType
ATTRIBUTE_MANDATORY
Fields inherited from interface org.ametys.plugins.forms.question.types.MultipleAwareFormQuestionType
ATTRIBUTE_MULTIPLE
Fields inherited from interface org.ametys.plugins.forms.question.types.RestrictiveQuestionType
ATTRIBUTE_READING, ATTRIBUTE_READING_CHECKBOX, ATTRIBUTE_WRITING, ATTRIBUTE_WRITING_CHECKBOX, INITIAL_WORKFLOW_ID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected SimpleViewItemGroup
Define the content of the advanced tabprotected ModelItem
_getEntryModelItem
(FormQuestion question) Define the entry model itemsprotected SimpleViewItemGroup
Define the content of the main tabGet the list of ModelItemsvoid
doAdditionalOperations
(FormQuestion question, Map<String, Object> values) Do additional operations to create or edit the questionGet the default title depending on typegetFieldToDisableIfFormPublished
(FormQuestion question) Get field to disable if form is publishedgetJSConverter
(FormQuestion question) Get the js converter for the choice listgetJSRenderer
(FormQuestion question) Get the js renderer for the choice listgetMandatoryValidator
(FormQuestion question) Create a validator that should be added to the element definition return by FormQuestionType.getEntryModelgetOptions
(FormQuestion question) Get options of the choices listgetOtherFieldModel
(FormQuestion question) Get other field modelgetSourceType
(FormQuestion question) Get type of source for this questiongetStorageType
(FormQuestion question) Get the storage type of the question typeboolean
hasOtherOption
(FormQuestion question) true
if the choice list can have an other valueboolean
isQuestionConfigured
(FormQuestion question) Say if question needs more configuration to be usedvoid
saxAdditionalInfos
(ContentHandler contentHandler, FormQuestion question) Sax additional informations for the question typevoid
saxEntryValue
(ContentHandler contentHandler, FormQuestion question, FormEntry entry) Sax the entry value depending on the question typevoid
service
(ServiceManager manager) void
validateEntryValues
(FormQuestion question, Map<String, Object> values, Multimap<String, I18nizableText> errors, Optional<Long> currentStepId) Validate values to create a form entryvoid
validateQuestionValues
(Map<String, Object> values, Map<String, I18nizableText> errors) Validate values to create or edit the questionvalueToJSONForClient
(Object value, FormQuestion question, FormEntry entry, ModelItem modelItem) Convert the entry value into a JSON object to use client sideMethods inherited from class org.ametys.plugins.forms.question.types.AbstractFormQuestionType
_getTabs, getWorkflowDescriptor
Methods inherited from class org.ametys.plugins.forms.question.types.AbstractStaticFormQuestionType
_createAdvancedTab, _createMainTab, _getRulesTab, configure, getCategory, getDescription, getDisplayOrder, getDisplayXSLT, getEntryModel, getIconGlyph, getId, getLabel, getModel, getScripts, getView, setPluginInfo
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.ametys.plugins.forms.question.types.ConfidentialAwareQuestionType
getConfidentialityModelItem, getConfidentialityViewElement
Methods inherited from interface org.ametys.plugins.forms.question.types.DescriptibleFormQuestionType
getDescription, getDescriptionModelItem, getDescriptionViewElement
Methods inherited from interface org.ametys.plugins.forms.question.FormQuestionType
canBeAnsweredByUser, isCacheable, onlyForDisplay
Methods inherited from interface org.ametys.plugins.forms.question.types.IllustrableFormQuestionType
getIllustration, getIllustrationAlternative, getIllustrationModelItems, getIllustrationTab
Methods inherited from interface org.ametys.plugins.forms.question.types.MandatoryAwareFormQuestionType
getMandatoryModelItem, getMandatoryViewElement, isMandatory
Methods inherited from interface org.ametys.plugins.forms.question.types.MultipleAwareFormQuestionType
getMultipleModelItem, getMultipleViewElement, isMultiple
Methods inherited from interface org.ametys.plugins.forms.question.types.RestrictiveQuestionType
getReadingSteps, getRestrictiveModelItems, getRestrictiveTab, getWritingSteps, isModifiable, isReadRestricted
-
Field Details
-
ATTRIBUTE_SOURCE_TYPE
Constant for source type attribute- See Also:
-
ATTRIBUTE_OTHER
Constant for other option attribute- See Also:
-
ATTRIBUTE_FORMAT
Constant for the format attribute- See Also:
-
ATTRIBUTE_PLACEHOLDER
Constant for placeholder attribute.- See Also:
-
DEFAULT_TYPE_ID
Id of the default type for formatStaticEnumerator- See Also:
-
CHECKBOX_FORMAT_VALUE
Name of checkbox formatStaticEnumerator entry- See Also:
-
COMBOBOXBOX_FORMAT_VALUE
Name of combobox formatStaticEnumerator entry- See Also:
-
OTHER_OPTION_VALUE
Label of the other option value- See Also:
-
OTHER_PREFIX_DATA_NAME
Label of the other option value- See Also:
-
DEFAULT_TITLE
Constant for default title- See Also:
-
_choiceSourceTypeExtensionPoint
The choice source type extension point
-
-
Constructor Details
-
ChoicesListQuestionType
public ChoicesListQuestionType()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractFormQuestionType
- Throws:
ServiceException
-
_getModelItems
Description copied from class:AbstractStaticFormQuestionType
Get the list of ModelItems- Overrides:
_getModelItems
in classAbstractFormQuestionType
- Returns:
- a list of ModelItems
-
_getMainTab
Description copied from class:AbstractFormQuestionType
Define the content of the main tab- Overrides:
_getMainTab
in classAbstractFormQuestionType
- Returns:
- the main tab definition
-
_getAdvancedTab
Description copied from class:AbstractFormQuestionType
Define the content of the advanced tab- Overrides:
_getAdvancedTab
in classAbstractFormQuestionType
- Returns:
- the advanced tab definition
-
getOptions
Get options of the choices list- Parameters:
question
- The current question- Returns:
- a map of the options: key is optionValue, value is optionLabel
-
saxAdditionalInfos
public void saxAdditionalInfos(ContentHandler contentHandler, FormQuestion question) throws SAXException Description copied from interface:FormQuestionType
Sax additional informations for the question type- Specified by:
saxAdditionalInfos
in interfaceFormQuestionType
- Overrides:
saxAdditionalInfos
in classAbstractStaticFormQuestionType
- Parameters:
contentHandler
- the content handlerquestion
- the question- Throws:
SAXException
- if a saxing error occurred
-
getStorageType
Description copied from interface:FormQuestionType
Get the storage type of the question type- Specified by:
getStorageType
in interfaceFormQuestionType
- Parameters:
question
- the question- Returns:
- the storage type
-
_getEntryModelItem
Description copied from class:AbstractStaticFormQuestionType
Define the entry model items- Overrides:
_getEntryModelItem
in classAbstractFormQuestionType
- Parameters:
question
- the question- Returns:
- the entry model item
-
doAdditionalOperations
Description copied from interface:FormQuestionType
Do additional operations to create or edit the question- Specified by:
doAdditionalOperations
in interfaceFormQuestionType
- Overrides:
doAdditionalOperations
in classAbstractStaticFormQuestionType
- Parameters:
question
- the questionvalues
- the values
-
getDefaultTitle
Description copied from interface:FormQuestionType
Get the default title depending on type- Specified by:
getDefaultTitle
in interfaceFormQuestionType
- Returns:
- the default title
-
isQuestionConfigured
Description copied from interface:FormQuestionType
Say if question needs more configuration to be used- Specified by:
isQuestionConfigured
in interfaceFormQuestionType
- Overrides:
isQuestionConfigured
in classAbstractStaticFormQuestionType
- Parameters:
question
- the current question- Returns:
- false if question needs more configuration, true by default
-
getSourceType
Get type of source for this question- Parameters:
question
- the current question- Returns:
- the ChoiceSourceType
-
saxEntryValue
public void saxEntryValue(ContentHandler contentHandler, FormQuestion question, FormEntry entry) throws SAXException Description copied from interface:FormQuestionType
Sax the entry value depending on the question type- Specified by:
saxEntryValue
in interfaceFormQuestionType
- Overrides:
saxEntryValue
in classAbstractStaticFormQuestionType
- Parameters:
contentHandler
- the content handlerquestion
- the question getting saxedentry
- the entry- Throws:
SAXException
- exception while saxing entry
-
getFieldToDisableIfFormPublished
Description copied from interface:FormQuestionType
Get field to disable if form is published- Specified by:
getFieldToDisableIfFormPublished
in interfaceFormQuestionType
- Overrides:
getFieldToDisableIfFormPublished
in classAbstractFormQuestionType
- Parameters:
question
- the form question- Returns:
- the list of field name
-
validateQuestionValues
Description copied from interface:FormQuestionType
Validate values to create or edit the question- Specified by:
validateQuestionValues
in interfaceFormQuestionType
- Overrides:
validateQuestionValues
in classAbstractStaticFormQuestionType
- Parameters:
values
- the valueserrors
- the errors
-
getMandatoryValidator
Description copied from interface:MandatoryAwareFormQuestionType
Create a validator that should be added to the element definition return by FormQuestionType.getEntryModel- Specified by:
getMandatoryValidator
in interfaceMandatoryAwareFormQuestionType
- Parameters:
question
- the question- Returns:
- a validator
-
validateEntryValues
public void validateEntryValues(FormQuestion question, Map<String, Object> values, Multimap<String, I18nizableText> errors, Optional<Long> currentStepId) Description copied from interface:FormQuestionType
Validate values to create a form entry- Specified by:
validateEntryValues
in interfaceFormQuestionType
- Overrides:
validateEntryValues
in classAbstractStaticFormQuestionType
- Parameters:
question
- the questionvalues
- the valueserrors
- the errorscurrentStepId
- the current step id of the entry. Can be empty if the form has no workflow
-
getOtherFieldModel
Get other field model- Parameters:
question
- the question- Returns:
- the other field model
-
hasOtherOption
true
if the choice list can have an other value- Parameters:
question
- the question- Returns:
true
if the choice list can have an other value
-
getJSRenderer
Description copied from interface:FormQuestionType
Get the js renderer for the choice list- Specified by:
getJSRenderer
in interfaceFormQuestionType
- Parameters:
question
- the question- Returns:
- the js renderer
-
getJSConverter
Description copied from interface:FormQuestionType
Get the js converter for the choice list- Specified by:
getJSConverter
in interfaceFormQuestionType
- Parameters:
question
- the question- Returns:
- the js converter
-
valueToJSONForClient
public Object valueToJSONForClient(Object value, FormQuestion question, FormEntry entry, ModelItem modelItem) throws Exception Description copied from interface:FormQuestionType
Convert the entry value into a JSON object to use client side- Specified by:
valueToJSONForClient
in interfaceFormQuestionType
- Parameters:
value
- the value to convertquestion
- the form questionentry
- the form entrymodelItem
- the model item- Returns:
- The value as JSON
- Throws:
Exception
- if an error occurred
-