|
||||||||||
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.Select
fc.web.forms.RefreshableSelect
public final class RefreshableSelect
An refreshable HTML Select field. This is different than Select
in that is allows the values/options displayed by this select to be
changed dynamically/per-user via the setValue(FormData, List)
method.
There is no easy way to persistently keep track of these values which may be different for each user. Therefore, unlike other field classes, this class does (by default) no check to see if the returned values by the user match at least one of the values displayed to the user in the first place. This can happen if values are hacked on the client side.
Database constraints (that only accept valid values) should be used to possibly handle bad data returned by this field.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class fc.web.forms.Select |
---|
Select.Option |
Nested classes/interfaces inherited from class fc.web.forms.Field |
---|
Field.Type |
Constructor Summary | |
---|---|
RefreshableSelect(java.lang.String name)
Creates a new select element with no initial values. |
|
RefreshableSelect(java.lang.String name,
java.util.List values)
Creates a new select element with the specified initial values and no multiple selections allowed. |
Method Summary | |
---|---|
void |
add(Select.Option opt)
Adds a new option to the selection list. |
void |
add(java.lang.String item)
Adds a new option to the selection list. |
Select |
allowMultiple(boolean allow)
true is 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)
|
void |
reset()
Clears all data in this select. |
void |
setSelectedValue(FormData fd,
int value)
Convenience method that invokes #setSelectedValue(fd, String)
after converting the specified integer value to a string. |
void |
setSelectedValue(FormData fd,
java.lang.String value)
Convenience method that sets the options for this select in the specified form data. |
Select |
setSize(int size)
This value (if set) is rendered as the html SIZE tag. |
void |
setValue(FormData fd,
java.util.List values)
Sets the options 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.Select |
---|
makeOptionsFromQuery, makeOptionsFromQuery, setValue, useQuery, useQuery |
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 RefreshableSelect(java.lang.String name)
name
- the field namepublic RefreshableSelect(java.lang.String name, java.util.List values)
name
- the field namevalues
- the initial option values for this class. The
objects contained in the list must be of type
Select.Option
otherwise a
ClassCastException may be thrown in
future operations on this object.
java.lang.IllegalArgumentException
- if the values parameter was null
(note: an empty but non-null List is ok)Method Detail |
---|
public Field.Type getType()
Field
Field.Type
. This type
is rendered as part of <input type= ...
getType
in class Select
public void setValue(FormData fd, java.util.List values)
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.
fd
- the non-null form data used for rendering the formvalues
- a list of Select.Option
objectspublic void setSelectedValue(FormData fd, java.lang.String value)
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 selected value.
fd
- the non-null form data used for rendering the formvalue
- the option with this value is selectedpublic void setSelectedValue(FormData fd, int value)
#setSelectedValue(fd, String)
after converting the specified integer value to a string.
public java.util.List getValue(FormData fd)
Select.Option
. If there
are no selected options, the returned list will be an
empty list.
getValue
in class Select
fd
- the submited form data. This object should not be null
otherwise a NPE will be thrown.public java.lang.String getStringValue(FormData fd)
The returned value is of type String obtained by called the
selected Option's Select.Option.getValue()
method.
If there is no selection, returns null
getStringValue
in class Select
public int getIntValue(FormData fd)
All the caveats of #getSingleValueAsString()
apply.
getIntValue
in class Select
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.
getBooleanValue
in class Select
public boolean isFilled(FormData fd)
isFilled
in class Select
public void setValueFromSubmit(FormData fd, javax.servlet.http.HttpServletRequest req) throws SubmitHackedException
Field
setValueFromSubmit
in class Select
fd
- the form data object to store the value in
SubmitHackedException
public void renderImpl(FormData fd, java.io.Writer writer) throws java.io.IOException
renderImpl
in class Select
java.io.IOException
public void add(Select.Option opt)
add
in class Select
opt
- the option to be addedpublic void add(java.lang.String item)
add(new Select.Option(item))
method was invoked.
add
in class Select
item
- the option to be addedpublic void reset()
reset
in class Select
public Select setSize(int size)
setSize
in class Select
public Select allowMultiple(boolean allow)
allowMultiple
in class Select
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |