|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfc.web.forms.Field
fc.web.forms.DependentField
fc.web.forms.DependentSelect
public final class DependentSelect
A dependent HTML DependentSelect field. The values of this field change based on the chosen value of some other field in the form. These new values are calculated/set on the server side.
Another good (and equally valid) approach is to instead use javascript arrays (with different sets of values) and swap out values on the client and/or use AJAX on the client side.
Nested Class Summary | |
---|---|
static class |
DependentSelect.Data
|
Nested classes/interfaces inherited from class fc.web.forms.Field |
---|
Field.Type |
Constructor Summary | |
---|---|
DependentSelect(java.lang.String name)
Creates a new select element with no initial values. |
Method Summary | |
---|---|
DependentSelect |
allowMultiple(FormData fd,
boolean allow)
true if multiple selections are allowed, false otherwise. |
boolean |
getBooleanValue(FormData fd)
Convenience method that returns the single value of this field as a boolean. |
int |
getIntValue(FormData fd)
Convenience method that returns the single value of this field as a Integer. |
java.lang.String |
getStringValue(FormData fd)
Convenience method that returns the selected option as a String. |
Field.Type |
getType()
Subclasses should return an appropriate Field.Type . |
java.util.List |
getValue(FormData fd)
Returns a List containing the selected options. |
boolean |
isFilled(FormData fd)
Returns true if some option has been selected by the user, false otherwise. |
void |
renderImpl(FormData fd,
java.io.Writer writer)
|
DependentSelect |
setSize(FormData fd,
int size)
This value (if set) is rendered as the html SIZE tag. |
void |
setValue(DependentSelect.Data data,
java.util.List values)
Convenience method to set values in the specified DependentSelect.Data object. |
void |
setValue(FormData fd,
java.util.List values)
Sets the selected values for this select in the specified form data. |
void |
setValueFromSubmit(FormData fd,
javax.servlet.http.HttpServletRequest req)
This method sets the value of this field from the parameters obtained from the specified request. |
Methods inherited from class fc.web.forms.DependentField |
---|
addDependency |
Methods inherited from class fc.web.forms.Field |
---|
add, addError, addLabel, addString, disable, disable, enable, enable, getLabel, getName, getValidateErrors, isEnabled, render, render, render, renderError, renderError, renderStyleTag, setStyleTag, toString, validate |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DependentSelect(java.lang.String name)
name
- the field nameMethod Detail |
---|
public Field.Type getType()
Field
Field.Type
. This type
is rendered as part of <input type= ...
getType
in class Field
public java.util.List getValue(FormData fd)
Select.Option
. If there
are no selected options, the returned list will be an empty list.
fd
- the submited form datapublic java.lang.String getStringValue(FormData fd)
The returned value is of type String obtained by called the selected
Select.Option's Select.Option.getValue()
method.
If there is no selection, returns null
public int getIntValue(FormData fd)
All the caveats of #getSingleValueAsString()
apply.
java.lang.NumberFormatException
- if the value could not be
returned as in integer.public boolean getBooleanValue(FormData fd)
All the caveats of #getSingleValueAsString()
apply.
In particular, the formdata should contain non-null data
with at least one selection.
public boolean isFilled(FormData fd)
isFilled
in class Field
public void setValueFromSubmit(FormData fd, javax.servlet.http.HttpServletRequest req)
Field
setValueFromSubmit
in class Field
fd
- the form data object to store the value inSelect.setValueFromSubmit(fc.web.forms.FormData, javax.servlet.http.HttpServletRequest)
public void renderImpl(FormData fd, java.io.Writer writer) throws java.sql.SQLException, java.io.IOException
renderImpl
in class Field
java.sql.SQLException
java.io.IOException
public DependentSelect allowMultiple(FormData fd, boolean allow)
public DependentSelect setSize(FormData fd, int size)
public void setValue(FormData fd, java.util.List values)
DependentSelect.Data
object which is then stored
inside the form data. Since these are set in the FormData object, these
values are request specific and can differ per user.
If the form has not been submitted, there is no form data object. A form data object should be manually created if needed for storing the value.
data
- an existing form data object.values
- a list of Select.Option
objectspublic void setValue(DependentSelect.Data data, java.util.List values)
DependentSelect.Data
object.
The following two are equivalent:
andList values ..... DependentSelect.Data data = new DependentSelect.Data(); fd.putData(name, data); setValue(data, values);
List values ..... setValue(fd, values);
data
- an existing DependentSelect.Data object.values
- a list of Select.Option
objects
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |