|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.click.control.AbstractControl net.sf.click.control.Field net.sf.click.control.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 |
fieldWidths
The map of field width values. |
protected String |
legend
The FieldSet legend. |
protected Map |
legendAttributes
The FieldSet legend attributes map. |
protected boolean |
showBorder
The render fieldset border flag, default value is true. |
Fields inherited from class net.sf.click.control.Field |
disabled, error, focus, form, help, label, readonly, required, tabindex, title, validate, value |
Fields inherited from class net.sf.click.control.AbstractControl |
actionListener, attributes, listener, listenerMethod, messages, name, parent, styles |
Fields inherited from interface net.sf.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 |
getControlMap()
Return the map of controls where each map's key / value pair will consist of the control name and instance. |
List |
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 |
getFieldList()
Return the List of fields in the same order they were added to the fieldset. |
Map |
getFields()
Return the Map of fieldset fields, keyed on field name. |
Map |
getFieldWidths()
Return the map of field width values, keyed on field name. |
String |
getHtmlImports()
Return the HTML head import statements for contained fields. |
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 |
getLegendAttributes()
Return the fieldset attributes Map. |
boolean |
getShowBorder()
Return the render fieldset border flag. |
String |
getTag()
Return the fieldsets'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()
The on destroy request event handler. |
void |
onInit()
The on initialize event handler. |
boolean |
onProcess()
Process the request invoking onProcess() on the contained Control elements. |
void |
onRender()
The on render event handler. |
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 |
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 fieldsets form fields to the string buffer. |
void |
setActionListener(ActionListener actionListener)
This method is not supported and will throw a UnsupportedOperationException. |
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 |
setListener(Object listener,
String method)
This method is not supported and will throw a UnsupportedOperationException. |
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. |
String |
toString()
Returns the HTML representation of the FieldSet. |
Methods inherited from class net.sf.click.control.Field |
bindRequestValue, getError, getErrorLabel, getFocus, getFocusJavaScript, getForm, getHelp, getId, getLabel, getRequestValue, getTabIndex, getTextAlign, getTitle, getValidate, getValidationJavaScript, getValue, getValueObject, getWidth, isHidden, isRequired, isValid, setError, setErrorMessage, setErrorMessage, setErrorMessage, setErrorMessage, setFocus, setHelp, setLabel, setParent, setRequired, setTabIndex, setTextAlign, setTitle, setValidate, setValue, setValueObject, setWidth, validate |
Methods inherited from class net.sf.click.control.AbstractControl |
addStyleClass, appendAttributes, getActionListener, getAttribute, getAttributes, getContext, getMessage, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasStyles, onDeploy, registerActionEvent, removeStyleClass, renderTagBegin, renderTagEnd, 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 net.sf.click.Control |
getContext, getId, getMessages, getName, getParent, onDeploy, setName, setParent |
Field Detail |
protected Map fieldWidths
protected String legend
protected Map 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)
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, the container already contains a control with the same
name or if the control is neither a Field nor FieldSetContainer.add(net.sf.click.Control)
public Control add(Control control)
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, the container already contains a control with the same
name or if the control is neither a Field nor FieldSetContainer.add(net.sf.click.Control).
public Field add(Field field)
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, the field name
is not defined or the fieldSet already contains a control with the same
nameadd(net.sf.click.Control)
public Field add(Field field, int width)
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, the fieldset already
contains a field with the same name or the width < 1public Control add(Control control, int width)
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, the fieldSet already contains a control with the
same name 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(net.sf.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 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(net.sf.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
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 getFieldList()
public Map getFields()
public Map getFieldWidths()
public void setForm(Form form)
setForm
in class Field
form
- FieldSet's parent Formpublic String getHtmlImports()
getHtmlImports
in interface Control
getHtmlImports
in class AbstractControl
Control.getHtmlImports()
public 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 getLegendAttributes()
public boolean hasLegendAttributes()
public boolean onProcess()
onProcess
in interface Control
onProcess
in class Field
public void onDestroy()
Control
Container
implementations should recursively
invoke the onDestroy method on each of their child controls ensuring that
all controls receive this event.
Please note: a common problem when overriding onDestroy in
subclasses is forgetting to call super.onDestroy(). Consider
carefully whether you should call super.onDestroy() or not,
especially for Container
s which by default
call onDestroy on all their child controls as well.
onDestroy
in interface Control
onDestroy
in class AbstractControl
Control.onDestroy()
public void onInit()
Control
Control.onProcess()
method is called.
Container
implementations should recursively
invoke the onInit method on each of their child controls ensuring that
all controls receive this event.
Please note: a common problem when overriding onInit in
subclasses is forgetting to call super.onInit(). Consider
carefully whether you should call super.onInit() or not,
especially for Container
s which by default
call onInit on all their child controls as well.
onInit
in interface Control
onInit
in class Field
Control.onInit()
public void onRender()
Control
Container
implementations should recursively
invoke the onRender method on each of their child controls ensuring that
all controls receive this event.
Please note: a common problem when overriding onRender in
subclasses is forgetting to call super.onRender(). Consider
carefully whether you should call super.onRender() or not,
especially for Container
s which by default
call onRender on all their child controls as well.
onRender
in interface Control
onRender
in class AbstractControl
Control.onRender()
public void setListener(Object listener, String method)
setListener
in interface Control
setListener
in class Field
listener
- the listener object with the named method to invokemethod
- the name of the method to invokeControl.setListener(Object, String)
public void setActionListener(ActionListener actionListener)
setActionListener
in class AbstractControl
actionListener
- the control's action listenerAbstractControl.setActionListener(ActionListener)
public 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(net.sf.click.util.HtmlStringBuffer)
public String toString()
render(net.sf.click.util.HtmlStringBuffer)
. The size of buffer
is determined by getControlSizeEst()
.
toString
in class AbstractControl
Object.toString()
protected Map 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 |