Class SplibThymeleafOptionUtil
It's called from thymeleaf.
Options are in the format of csv and able to receive multiple optional attributes.
It's written like 'readonly,required'.
It also receives key value parameter like 'readonly,id=deptName,required'.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetElementFromPsv(String options, String key, int psvIndex) Obtains an element string from designated ordinal number of pipe separated values (psv) format string from designated index of multiple option values.getElementFromPsvOrElse(String options, String key, int psvIndex, String defaultValue) Returns getElementFromPsv or else.getElementFromValuesOfPsv(String options, String key, int arrayIndex, int psvIndex) Obtains an element from an array of psv strings.getElementFromValuesOfPsvOrElse(String options, String key, int arrayIndex, int psvIndex, String defaultValue) Obtains an element from an array of psv strings or else.Returns value obtained from the key.getValueOrElse(String options, String key, String defaultValue) Returns value obtained from the key, or defaultValue when the key does not exist in the properties file.String[]Returns values obtained from the key as an array.getValuesInSpaceSeparetedFormat(String options, String key) Returns values in space separated format.booleanReturns if specified key exists in options.
-
Constructor Details
-
SplibThymeleafOptionUtil
public SplibThymeleafOptionUtil()Constructs a new instance.
-
-
Method Details
-
hasKey
-
getValue
-
getValueOrElse
-
getValues
Returns values obtained from the key as an array.When you want to give multiple options of the same key (like add 2 classes to an element), you are supposed to set 2 key-value pairs, like 'classappend=class1,classapeend=class2'. In this case getValues(options, 'classappend') return {'class1', 'class2'}.
- Parameters:
options- optionskey- key- Returns:
- value
-
getValuesInSpaceSeparetedFormat
-
getElementFromPsv
Obtains an element string from designated ordinal number of pipe separated values (psv) format string from designated index of multiple option values.For example, option: 'attr' is used for th:attr to add attribute dynamically to the tag.
'attr' needs to have its key and value, so option format becomes 'attr=key1|value1'.
(when a single option needs to have multiple different meaning string like key and value, option should be pipe separated format.
When you want to list multiple strings of same meaning set xxx=yyy multiple times (like 'classappend=mt-3,classappend=mb-3')) -
getElementFromPsvOrElse
-
getElementFromValuesOfPsv
-
getElementFromValuesOfPsvOrElse
-