|
||||||||||
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.extras.control.AbstractContainerField
Provides an abstract convenience class that implements Container and extend Field.
AbstractContainerField delegates Contain specific actions to an internal Container instance. You can access the Container instance throughgetContainer()
.
If you need to bind a request parameter to this fields value, please see
bindRequestValue()
.
Here is an example of a Border Control that can wrap a Button and render
a div border around it.
public class ButtonBorder extends AbstractContainerField { public ButtonBorder(String name) { super(name); } public String getTag() { return "div"; } public Control addControl(Button button) { return getContainer().addControl(button); } }
Field Summary | |
protected AbstractContainer |
container
Internal container instance. |
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 | |
AbstractContainerField()
Create an AbstractContainerField with no name defined. |
|
AbstractContainerField(String name)
Create an AbstractContainerField with the given name. |
|
AbstractContainerField(String name,
String label)
Construct an AbstractContainerField with the given name and label. |
Method Summary | |
Control |
add(Control control)
|
void |
bindRequestValue()
This method does nothing by default. |
boolean |
contains(Control control)
|
Container |
getContainer()
Return the internal container instance. |
Control |
getControl(String controlName)
|
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()
|
protected int |
getControlSizeEst()
|
String |
getHtmlImports()
Return the HTML head import statements for contained controls. |
boolean |
hasControls()
Returns true if this container has existing controls, false otherwise. |
Control |
insert(Control control,
int index)
|
void |
onDestroy()
|
void |
onInit()
|
boolean |
onProcess()
|
void |
onRender()
|
boolean |
remove(Control control)
|
void |
render(HtmlStringBuffer buffer)
By default render the container and all its child controls to the specified buffer. |
protected void |
renderChildren(HtmlStringBuffer buffer)
Render this container children to the specified buffer. |
protected void |
renderContent(HtmlStringBuffer buffer)
Render this container content to the specified buffer. |
protected void |
renderTagEnd(String tagName,
HtmlStringBuffer buffer)
|
void |
setParent(Object parent)
Set the parent of the Field. |
String |
toString()
Returns the HTML representation of this control. |
Methods inherited from class net.sf.click.control.Field |
getError, getErrorLabel, getFocus, getFocusJavaScript, getForm, getHelp, getId, getLabel, getRequestValue, getTabIndex, getTextAlign, getTitle, getValidate, getValidationJavaScript, getValue, getValueObject, getWidth, isDisabled, isHidden, isReadonly, isRequired, isValid, setDisabled, setError, setErrorMessage, setErrorMessage, setErrorMessage, setErrorMessage, setFocus, setForm, setHelp, setLabel, setListener, setReadonly, 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, getTag, hasAttribute, hasAttributes, hasStyles, onDeploy, registerActionEvent, removeStyleClass, renderTagBegin, 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 net.sf.click.Control |
getContext, getId, getMessages, getName, getParent, onDeploy, setListener, setName |
Field Detail |
protected AbstractContainer container
Constructor Detail |
public AbstractContainerField()
public AbstractContainerField(String name)
name
- the ContainerField namepublic AbstractContainerField(String name, String label)
name
- the name of the Fieldlabel
- the label of the FieldMethod Detail |
public Control add(Control control)
add
in interface Container
control
- the control to add to the container and return
Container.add(net.sf.click.Control).
public Control insert(Control control, int index)
insert
in interface Container
control
- the control to add to the container and returnindex
- the index at which the control is to be inserted
Container.insert(net.sf.click.Control, int).
public boolean remove(Control control)
remove
in interface Container
control
- the control to remove from the container
Container.remove(net.sf.click.Control)
public Container getContainer()
public List getControls()
getControls
in interface Container
Container.getControls()
public Control getControl(String controlName)
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)
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 void setParent(Object parent)
setParent
in interface Control
parent
- the parent of the Control
IllegalArgumentException
- if the given parent instance is
referencing this object: if (parent == this)Control.setParent(Object)
public String getHtmlImports()
getHtmlImports
in interface Control
Control.getHtmlImports()
public void bindRequestValue()
public CoolField extends AbstractContainerField { public CoolField(String name) { super(name); } public void bindRequestValue() { setValue(getRequestValue()); } // Below is the actual getRequestValue implementation as defined // in Field. This is done solely to show how to retrieve the // request parameter based on the fields name. protected String getRequestValue() { String value = getContext().getRequestParameter(getName()); if (value != null) { return value.trim(); } else { return ""; } } }Note you can use method
Field.getRequestValue()
to retrieve the
fields value if the request parameter is the fields name.
public boolean onProcess()
onProcess
in interface Control
Control.onProcess()
public void onDestroy()
onDestroy
in interface Control
Control.onDestroy()
public void onInit()
onInit
in interface Control
Control.onInit()
public void onRender()
onRender
in interface Control
Control.onRender()
public void render(HtmlStringBuffer buffer)
AbstractControl.getTag()
returns null,
this method will render only its child controls.
render
in interface Control
buffer
- 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 getControlSizeEst()
.
protected void renderTagEnd(String tagName, HtmlStringBuffer buffer)
tagName
- the name of the tag to closebuffer
- the buffer to append the output toAbstractControl.renderTagEnd(java.lang.String, net.sf.click.util.HtmlStringBuffer)
protected void renderContent(HtmlStringBuffer buffer)
buffer
- the buffer to append the output toAbstractContainer.renderContent(net.sf.click.util.HtmlStringBuffer)
protected void renderChildren(HtmlStringBuffer buffer)
buffer
- the buffer to append the output toAbstractContainer.renderChildren(net.sf.click.util.HtmlStringBuffer)
protected Map getControlMap()
AbstractContainer.getControlMap()
protected int getControlSizeEst()
AbstractControl.getControlSizeEst()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |