|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.click.control.AbstractControl
net.sf.click.control.AbstractContainer
net.sf.click.control.FieldSet
Provides a FieldSet container control: <fieldset>.
Form and BasicForm, however
the behavior of FieldSet differs for each.
Form.renderFieldSet(net.sf.click.util.HtmlStringBuffer, net.sf.click.control.FieldSet)
thus using the properties of its parent Form for laying out and rendering of
its fields.
A FieldSet can contain any Control, however when used in conjuction
with Form, it is recommended to only add fields since Form's
auto-layout is geared towards the layout of fields.
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 BasicForm |
form
The parent BasicForm. |
protected String |
label
The FieldSet label. |
protected String |
legend
The FieldSet legend. |
protected Map |
legendAttributes
The FieldSet legend attributes map. |
protected boolean |
showBorder
The render the fieldset border flag, default value is true. |
| Fields inherited from class net.sf.click.control.AbstractContainer |
controlMap, controls |
| 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 | |
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's width in columns. |
int |
getColumns()
Return the number of fieldset layout table columns. |
List |
getFieldList()
Return the List of fields, ordered in addition order 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. |
BasicForm |
getForm()
Return the parent Form containing the FieldSet or null if no form is present in the parent hierarchy. |
String |
getHtmlImports()
Return the HTML head import statements for contained fields. |
String |
getLabel()
Return the fieldSet display label. |
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 |
hasLegendAttributes()
Return true if the fieldset has attributes or false otherwise. |
Control |
insert(Control control,
int index)
Add a Field to the FieldSet and return the added instance. |
boolean |
onProcess()
Process the request invoking onProcess() on the contained Control elements. |
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 |
renderContent(HtmlStringBuffer buffer)
Render this container content to the specified buffer. |
protected void |
renderTagBegin(String tagName,
HtmlStringBuffer buffer)
Render the tag and common attributes. |
void |
setColumns(int columns)
Set the number of fieldset layout table columns. |
void |
setForm(BasicForm form)
Set the FieldSet's the parent Form. |
void |
setLabel(String label)
Set the Field display caption. |
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 |
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.AbstractContainer |
add, contains, getControl, getControlMap, getControls, getControlSizeEst, hasControls, onDestroy, onInit, onRender, renderChildren, renderTagEnd |
| Methods inherited from class net.sf.click.control.AbstractControl |
addStyleClass, appendAttributes, getActionListener, getAttribute, getAttributes, getContext, getId, getMessage, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasStyles, onDeploy, registerActionEvent, removeStyleClass, setActionListener, setAttribute, setId, setName, setParent, 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 BasicForm form
protected String label
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 value
public FieldSet(String name,
String legend)
name - the fieldset namelegend - the fieldset legend element valuepublic FieldSet()
| Method Detail |
public Control insert(Control control,
int index)
Form, the
Fields inside the FieldSet will be laid out by the Form.
insert in interface Containerinsert in class AbstractContainercontrol - 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, if the control's parent is a Page or if the control is neither a
Field nor FieldSetContainer.add(net.sf.click.Control)public Field add(Field field)
AbstractContainer.getControlMap() using its name.
Field instances will be add to AbstractContainer.getControls().
field - the field to add to the form
IllegalArgumentException - if the field is null, the field name
is not defined, the fieldSet already contains a control with the same name
or if the field's parent is a PageAbstractContainer.add(net.sf.click.Control)
public Field add(Field field,
int width)
field - the field to add to the fieldsetwidth - the width of the field in table columns
IllegalArgumentException - if the field is null, field's name is
not defined, a HiddenField, the fieldset already contains a control with
the same name, if the field's parent is a Page or the width < 1public boolean remove(Control control)
Container
remove in interface Containerremove in class AbstractContainercontrol - 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 String getTag()
getTag in class AbstractControlAbstractControl.getTag()public 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 List getFieldList()
public Map getFields()
public Map getFieldWidths()
public BasicForm getForm()
public void setForm(BasicForm form)
form - FieldSet's parent Formpublic String getHtmlImports()
getHtmlImports in interface ControlgetHtmlImports in class AbstractContainerControl.getHtmlImports()public String getLabel()
Field.getLabel()public void setLabel(String label)
label - the display label of the Fieldpublic 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 ControlonProcess in class AbstractContainerControl.onProcess().
public void setListener(Object listener,
String method)
setListener in interface ControlsetListener in class AbstractControllistener - the listener object with the named method to invokemethod - the name of the method to invokeControl.setListener(Object, String)public void render(HtmlStringBuffer buffer)
Form instance, this method will
delegate rendering to Form.renderFieldSet(net.sf.click.util.HtmlStringBuffer, net.sf.click.control.FieldSet).
The size of buffer is determined by AbstractContainer.getControlSizeEst().
render in interface Controlrender in class AbstractContainerbuffer - the specified buffer to render the control's output toAbstractControl.render(net.sf.click.util.HtmlStringBuffer)public String toString()
render(net.sf.click.util.HtmlStringBuffer). The size of buffer
is determined by AbstractContainer.getControlSizeEst().
toString in class AbstractContainerObject.toString()
protected void renderTagBegin(String tagName,
HtmlStringBuffer buffer)
AbstractControl
Field field = new TextField("mytext");
HtmlStringBuffer buffer = new HtmlStringBuffer();
field.renderTagBegin("div", buffer);
will be:
<div name="mytext" id="mytext"Note that the tag is not closed.
renderTagBegin in class AbstractControltagName - the name of the tag to renderbuffer - the buffer to append the output toAbstractControl.renderTagBegin(java.lang.String, net.sf.click.util.HtmlStringBuffer)protected void renderContent(HtmlStringBuffer buffer)
AbstractContainer
renderContent in class AbstractContainerbuffer - the buffer to append the output toAbstractContainer.renderContent(net.sf.click.util.HtmlStringBuffer)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||