|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.click.control.AbstractControl org.apache.click.control.Field org.apache.click.control.FieldSet
public class FieldSet
Provides a FieldSet container control: <fieldset>.
public class PaymentDetails() { public Form form = new Form(); public PaymentDetails() { FieldSet paymentFieldSet = new FieldSet("paymentDetails"); form.add(paymentFieldSet); paymentFieldSet.add(new TextField("cardName", true)); paymentFieldSet.add(new CreditCardField("cardNumber", true)); IntegerField expiryField = new IntegerField("expiry", true); expiryField.setSize(4); expiryField.setMaxLength(4); paymentFieldSet.add(expiryField); form.add(new Submit("ok", " OK ", this, "onOkClick"); form.add(new Submit(" Cancel ", this, "onCancelClick")); } }When the FieldSet is processed it invokes the onProcess() method of its contained Fields. Beyond this the FieldSet performs no server side processing, and should be considered simply as a container for laying out form fields. See also the W3C HTML reference: FIELDSET
Field Summary | |
---|---|
protected Integer |
columns
This property serves as a hint to the number of table columns the fieldset is rendered with. |
protected Map<String,Control> |
controlMap
The map of controls keyed by field name. |
protected List<Control> |
controls
The list of controls. |
protected List<Field> |
fieldList
The ordered list of fields, excluding buttons. |
protected Map<String,Integer> |
fieldWidths
The map of field width values. |
protected String |
legend
The FieldSet legend. |
protected Map<String,String> |
legendAttributes
The FieldSet legend attributes map. |
protected boolean |
showBorder
The render fieldset border flag, default value is true. |
Fields inherited from class org.apache.click.control.Field |
---|
disabled, error, focus, form, help, label, labelStyle, labelStyleClass, parentStyleClassHint, parentStyleHint, readonly, required, tabindex, title, trim, validate, value |
Fields inherited from class org.apache.click.control.AbstractControl |
---|
actionListener, attributes, behaviors, headElements, listener, listenerMethod, messages, name, parent, styles |
Fields inherited from interface org.apache.click.Control |
---|
CONTROL_MESSAGES |
Constructor Summary | |
---|---|
FieldSet()
Create a FieldSet with no name defined. |
|
FieldSet(String name)
Create a FieldSet with the given name. |
|
FieldSet(String name,
String legend)
Create a FieldSet with the given name and legend. |
Method Summary | |
---|---|
Control |
add(Control control)
Add a Control to the fieldset and return the added instance. |
Control |
add(Control control,
int width)
Add the control to the fieldset and specify the control's width in columns. |
Field |
add(Field field)
Add the field to the fieldSet, and set the fields form property. |
Field |
add(Field field,
int width)
Add the field to the fieldset and specify the field width in columns. |
boolean |
contains(Control control)
Return true if the container contains the specified control. |
int |
getColumns()
Return the number of fieldset layout table columns. |
Control |
getControl(String controlName)
Return the named control from the container if found or null otherwise. |
protected Map<String,Control> |
getControlMap()
Return the map of controls where each map's key / value pair will consist of the control name and instance. |
List<Control> |
getControls()
Return the sequential list of controls held by the container. |
protected int |
getControlSizeEst()
Return the estimated rendered control size in characters. |
Field |
getField(String name)
Return the named field if contained in the fieldset, or null if not found. |
List<Field> |
getFieldList()
Return the ordered list of FieldSet fields, excluding buttons. |
Map<String,Control> |
getFields()
Return the Map of fieldset fields, keyed on field name. |
Map<String,Integer> |
getFieldWidths()
Return the map of field width values, keyed on field name. |
String |
getLegend()
Return the fieldset Legend element value: <legend> If the legend value is null, this method will attempt to find a localized label message in the parent messages using the key: getName() + ".title" If not found then the message will be looked up in the /click-control.properties file using the same key. |
String |
getLegendAttribute(String name)
Return the legend HTML attribute with the given name, or null if the attribute does not exist. |
Map<String,String> |
getLegendAttributes()
Return the fieldset attributes Map. |
boolean |
getShowBorder()
Return the render fieldset border flag. |
Object |
getState()
Return the FieldSet state. |
String |
getTag()
Return the fieldset's html tag: fieldset. |
boolean |
hasControls()
Returns true if this container has existing controls, false otherwise. |
boolean |
hasLegendAttributes()
Return true if the fieldset has attributes or false otherwise. |
Control |
insert(Control control,
int index)
Add a Field to the FieldSet at the specified index and return the added instance. |
boolean |
isDisabled()
Return true if the FieldSet is disabled. |
boolean |
isReadonly()
Return true if the FieldSet is readonly. |
void |
onDestroy()
This method does nothing. |
void |
onInit()
This method does nothing. |
boolean |
onProcess()
Process the request invoking onProcess() on the contained Control elements. |
void |
onRender()
This method does nothing. |
boolean |
remove(Control control)
Remove the given control from the container, returning true if the control was found in the container and removed, or false if the control was not found. |
void |
remove(Field field)
Remove the given field from the fieldset. |
boolean |
removeField(String name)
Remove the named field from the fieldset, returning true if removed or false if not found. |
void |
removeState(Context context)
Remove the FieldSet state from the session for the given request context. |
void |
render(HtmlStringBuffer buffer)
Render the HTML representation of the FieldSet. |
protected void |
renderButtons(HtmlStringBuffer buffer)
Render the fieldset buttons to the string buffer. |
protected void |
renderFields(HtmlStringBuffer buffer)
Render the fieldset's form fields to the string buffer. |
Control |
replace(Control currentControl,
Control newControl)
Deprecated. this method was used for stateful pages, which have been deprecated |
void |
restoreState(Context context)
Restore the FieldSet state from the session for the given request context. |
void |
saveState(Context context)
Save the FieldSet state to the session for the given request context. |
void |
setColumns(int columns)
Set the number of fieldset layout table columns. |
void |
setDisabled(boolean disabled)
Set the FieldSet disabled flag which in turn will disable all its fields. |
void |
setForm(Form form)
Set the FieldSet's the parent Form. |
void |
setLegend(String legend)
Set the fieldset Legend element value: <legend>. |
void |
setLegendAttribute(String name,
String value)
Set the fieldset HTML attribute with the given attribute name and value. |
void |
setReadonly(boolean readonly)
Set the FieldSet readonly flag which in turn will set all its fields to readonly. |
void |
setShowBorder(boolean value)
Set the render fieldset border flag. |
void |
setState(Object state)
Set the FieldSet state. |
String |
toString()
Returns the HTML representation of the FieldSet. |
Methods inherited from class org.apache.click.control.Field |
---|
bindRequestValue, getError, getErrorLabel, getFocus, getFocusJavaScript, getForm, getHelp, getId, getLabel, getLabelStyle, getLabelStyleClass, getParentStyleClassHint, getParentStyleHint, getRequestValue, getTabIndex, getTextAlign, getTitle, getValidate, getValidationJavaScript, getValue, getValueObject, getWidth, isHidden, isRequired, isTrim, isValid, renderTagBegin, setError, setErrorMessage, setErrorMessage, setFocus, setHelp, setLabel, setLabelStyle, setLabelStyleClass, setListener, setParent, setParentStyleClassHint, setParentStyleHint, setRequired, setTabIndex, setTextAlign, setTitle, setTrim, setValidate, setValue, setValueObject, setWidth, validate |
Methods inherited from class org.apache.click.control.AbstractControl |
---|
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getHeadElements, getHtmlImports, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasBehaviors, hasStyles, isAjaxTarget, onDeploy, removeBehavior, removeStyleClass, renderTagEnd, setActionListener, setAttribute, setId, setName, setStyle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.click.Control |
---|
getBehaviors, getContext, getHeadElements, getId, getMessages, getName, getParent, hasBehaviors, isAjaxTarget, onDeploy, setListener, setName, setParent |
Field Detail |
---|
protected List<Control> controls
protected Map<String,Control> controlMap
protected final List<Field> fieldList
protected Map<String,Integer> fieldWidths
protected String legend
protected Map<String,String> legendAttributes
protected boolean showBorder
protected Integer columns
Form
acts upon this property.
Constructor Detail |
---|
public FieldSet(String name)
name
- the fieldset name element valuepublic FieldSet(String name, String legend)
name
- the fieldset namelegend
- the fieldset legend element valuepublic FieldSet()
Method Detail |
---|
public Control insert(Control control, int index)
replaced
by the given control. If a control has no name defined it cannot be replaced.
Controls can be retrieved from the Map controlMap
where the key is the Control name and value is the Control instance.
All controls are available on the controls
list
at the index they were inserted. If you are only interested in Fields,
note that fields are available on fieldList
.
The specified index only applies to controls
, not
fieldList
.
Please note if the specified control already has a parent assigned,
it will automatically be removed from that parent and inserted into the
fieldSet.
insert
in interface Container
control
- the control to add to the FieldSet and returnindex
- the index at which the control is to be inserted
IllegalArgumentException
- if the control is null, the Field's name
is not defined or if the control is neither a Field nor FieldSetContainer.insert(org.apache.click.Control, int)
public Control replace(Control currentControl, Control newControl)
replace
in interface Container
currentControl
- the current control container in the fieldsetnewControl
- the control to replace the current control
IllegalArgumentException
- if the currentControl or newControl is
null
IllegalStateException
- if the currentControl is not contained in
the fieldsetpublic Control add(Control control)
replaced
by the given control. If a control has no name defined it cannot be replaced.
Controls can be retrieved from the Map controlMap
where the key is the Control name and value is the Control instance.
All controls are available on the controls
list
in the order they were added. If you are only interested in Fields,
note fields are available on fieldList
.
add
in interface Container
control
- the control to add to the container and return
IllegalArgumentException
- if the control is null, the Field's name
is not defined or if the control is neither a Field nor FieldSetContainer.add(org.apache.click.Control).
public Field add(Field field)
replaced
by the given control. If a control has no name defined it cannot be replaced.
Fields can be retrieved from the Map fields
where
the key is the Field name and value is the Field instance.
Fields are available on fieldList
.
field
- the field to add to the fieldSet
IllegalArgumentException
- if the field is null or the field name
is not definedadd(org.apache.click.Control)
public Field add(Field field, int width)
replaced
by the given control. If a control has no name defined it cannot be replaced.
Fields can be retrieved from the Map fields
where
the key is the Field name and value is the Field instance.
Fields are available on fieldList
.
Note Button and HiddenField types are not valid arguments for this method.
field
- the field to add to the fieldsetwidth
- the width of the field in table columns
IllegalArgumentException
- if the field is null, field name is
not defined, field is a Button or HiddenField or the width < 1public Control add(Control control, int width)
replaced
by the given control. If a control has no name defined it cannot be replaced.
Controls can be retrieved from the Map controlMap
where the key is the Control name and value is the Control instance.
Controls are available on the controls
list.
Note Button and HiddenField types are not valid arguments for this method.
control
- the control to add to the fieldSetwidth
- the width of the control in table columns
IllegalArgumentException
- if the control is null, control is a
Button or HiddenField or the width < 1public boolean remove(Control control)
Container
remove
in interface Container
control
- the control to remove from the container
IllegalArgumentException
- if the control is nullContainer.remove(org.apache.click.Control)
public void remove(Field field)
field
- the field to remove from the fieldset
IllegalArgumentException
- if the field is nullpublic boolean removeField(String name)
name
- the name of the field to remove from the fieldset
public List<Control> getControls()
Container
getControls
in interface Container
Container.getControls()
public Control getControl(String controlName)
Container
getControl
in interface Container
controlName
- the name of the control to get from the container
Container.getControl(java.lang.String)
public boolean contains(Control control)
Container
contains
in interface Container
control
- the control whose presence in this container is to be tested
Container.contains(org.apache.click.Control)
public boolean hasControls()
hasControls
in interface Container
AbstractContainer.hasControls()
public String getTag()
getTag
in class AbstractControl
AbstractControl.getTag()
public boolean isDisabled()
isDisabled
in class Field
Field.setDisabled(boolean)
public void setDisabled(boolean disabled)
setDisabled
in class Field
disabled
- the Field disabled flagpublic boolean isReadonly()
isReadonly
in class Field
public void setReadonly(boolean readonly)
setReadonly
in class Field
readonly
- the FieldSet readonly flagpublic int getColumns()
Form
acts upon the column value.
By default this property inherits its value from the parent Form, but
can be specified to override the form value.
public void setColumns(int columns)
Form
acts upon the column value.
columns
- the number of fieldset layout table columnspublic boolean getShowBorder()
public void setShowBorder(boolean value)
value
- the render the fieldset border flagpublic Field getField(String name)
name
- the name of the field
public List<Field> getFieldList()
public Map<String,Control> getFields()
public Map<String,Integer> getFieldWidths()
public void setForm(Form form)
setForm
in class Field
form
- FieldSet's parent Formpublic String getLegend()
getName() + ".title"If not found then the message will be looked up in the /click-control.properties file using the same key. If a value cannot be found in the parent or control messages then the FieldSet name will be converted into a legend using the
ClickUtils.toLabel(String)
method.
public void setLegend(String legend)
legend
- the fieldset Legend element valuepublic String getLegendAttribute(String name)
name
- the name of legend HTML attribute
public void setLegendAttribute(String name, String value)
name
- the name of the form HTML attributevalue
- the value of the form HTML attribute
IllegalArgumentException
- if name parameter is nullpublic Map<String,String> getLegendAttributes()
public boolean hasLegendAttributes()
public boolean onProcess()
onProcess
in interface Control
onProcess
in class Field
Control.onProcess()
public void onDestroy()
AbstractControl
onDestroy
in interface Control
onDestroy
in class AbstractControl
Control.onDestroy()
public void onInit()
AbstractControl
onInit
in interface Control
onInit
in class AbstractControl
Control.onInit()
public void onRender()
AbstractControl
onRender
in interface Control
onRender
in class AbstractControl
Control.onRender()
public Object getState()
getState
in interface Stateful
getState
in class Field
public void setState(Object state)
setState
in interface Stateful
setState
in class Field
state
- the FieldSet state to setpublic void render(HtmlStringBuffer buffer)
getControlSizeEst()
.
render
in interface Control
render
in class AbstractControl
buffer
- the specified buffer to render the control's output toControl.render(org.apache.click.util.HtmlStringBuffer)
public void removeState(Context context)
removeState
in class Field
context
- the request contextsaveState(org.apache.click.Context)
,
restoreState(org.apache.click.Context)
public void restoreState(Context context)
setState(java.lang.Object)
to set the
field restored state.
restoreState
in class Field
context
- the request contextsaveState(org.apache.click.Context)
,
removeState(org.apache.click.Context)
public void saveState(Context context)
getState()
to retrieve the field state
to save.
saveState
in class Field
context
- the request contextrestoreState(org.apache.click.Context)
,
removeState(org.apache.click.Context)
public String toString()
render(org.apache.click.util.HtmlStringBuffer)
. The size of buffer
is determined by getControlSizeEst()
.
toString
in class AbstractControl
Object.toString()
protected Map<String,Control> getControlMap()
AbstractContainer.getControlMap()
protected int getControlSizeEst()
AbstractControl
getControlSizeEst
in class AbstractControl
AbstractControl.getControlSizeEst()
protected void renderFields(HtmlStringBuffer buffer)
buffer
- the StringBuffer to render toprotected void renderButtons(HtmlStringBuffer buffer)
buffer
- the StringBuffer to render to
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |