Class ChoiceGroup.Choice
java.lang.Object
fc.web.forms.ChoiceGroup.Choice
- Enclosing class:
ChoiceGroup
Creates a new choice for this choice group.
Also note that unlike other fields, the HTML label/text for this choice
has to be provided via the constructor (as opposed to being written at the
jsp level). See
htmlBeforeField.-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new unselected choice with the specified label (and no separate value attribute)Constructs a new unselected choice with the specified value and HTML text.Creates a new choice object. -
Method Summary
Modifier and TypeMethodDescriptionbooleanConvenience method that returns the value of this choice as a boolean.intConvenience method that returns the value of this choice as a Integer.getLabel()Returns the label for this choice.shortConvenience method that returns the value of this choice as a Short.getValue()Returns the value of this choice.booleanvoidBy default, the HTML label (if any) is written after the input element tag but calling this method reverses this order.voidRenders this choice maintaining it's selected state by using the specified form data.voidRenders this choice with the select state specified by theselectedparameter.voidsetLabelSeperator(String sep) Sets the seperator between labels and the choice.toString()voidwriteLabel(boolean val) Specifytrueto write the label for this choice,falseto skip the label.
-
Constructor Details
-
Choice
-
Choice
-
Choice
-
-
Method Details
-
labelBeforeField
By default, the HTML label (if any) is written after the input element tag but calling this method reverses this order. -
writeLabel
Specifytrueto write the label for this choice,falseto skip the label. By default, this istrue. (false is useful when just the radio button need to be shown, say in a table row with the label shown in a seperate header row). -
render
Renders this choice maintaining it's selected state by using the specified form data.Each choice can be rendered separately which helps in arbitrary html layout. Choices can also be rendered together via the parent
Field.render(FormData, Writer)method.- Throws:
IOException
-
render
Renders this choice with the select state specified by theselectedparameter.Each choice can be rendered separately which helps in arbitrary html layout. Choices can also be rendered together via the parent
Field.render(FormData, Writer)method.- Throws:
IOException
-
getValue
-
getIntValue
Convenience method that returns the value of this choice as a Integer.- Throws:
NumberFormatException- if the value could not be returned as an integer.
-
getShortValue
Convenience method that returns the value of this choice as a Short.- Throws:
NumberFormatException- if the value could not be returned as a short.
-
getBooleanValue
Convenience method that returns the value of this choice as a boolean. The value is converted into a boolean as per theBoolean.valueOf(String)method. -
getLabel
-
setLabelSeperator
Sets the seperator between labels and the choice. Defaults to a space if not set. -
isOrigSelected
- Returns:
trueif this field was originally set to selected,falseotherwise
-
toString
-