org.apache.click.extras.control
Class HtmlForm

java.lang.Object
  extended by org.apache.click.control.AbstractControl
      extended by org.apache.click.control.AbstractContainer
          extended by org.apache.click.control.Form
              extended by org.apache.click.extras.control.HtmlForm
All Implemented Interfaces:
Serializable, Control, Container, Stateful

public class HtmlForm
extends Form

Provides an HTML Form control to create composite based forms:   <form method='post'>.

Form uses an HTML Table to layout its fields and controls. HtmlForm on the other hand does not provide a layout and instead relies on the developer to compose a layout programmatically.

This allows developers to provide a more flexible and CSS friendly layout.

You can read more about programmatic layout here.

Also see this example of how HtmlForm is used to provide a custom layout.

Please note, for most cases Form is the better option as it provides automatic layout and error reporting.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.click.control.Form
actionURL, ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, buttonAlign, buttonList, buttonStyle, columns, defaultFieldSize, disabled, enctype, error, errorsAlign, errorsPosition, errorsStyle, fieldList, fieldStyle, fieldWidths, FOCUS_JAVASCRIPT, FORM_NAME, formSubmission, javaScriptValidation, labelAlign, labelsPosition, labelStyle, method, MULTIPART_FORM_DATA, POSITION_BOTTOM, POSITION_LEFT, POSITION_MIDDLE, POSITION_TOP, readonly, SUBMIT_CHECK, validate
 
Fields inherited from class org.apache.click.control.AbstractContainer
controlMap, controls
 
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
HtmlForm()
          Create an html form with no name.
HtmlForm(String name)
          Create an html form with the given name.
 
Method Summary
 Control add(Control control, int width)
          This method is not supported and throws an UnsupportedOperationException if invoked.
 Field add(Field field, int width)
          This method is not supported and throws an UnsupportedOperationException if invoked.
protected  int getFormSizeEst(List<Field> formFields)
           
 void render(HtmlStringBuffer buffer)
          Render the HTML representation of the form and all its child controls to the specified buffer.
protected  void renderChildren(HtmlStringBuffer buffer)
           
protected  void renderContent(HtmlStringBuffer buffer)
           
protected  void renderTagBegin(String tagName, HtmlStringBuffer buffer)
           
 
Methods inherited from class org.apache.click.control.Form
add, add, clearErrors, clearValues, copyFrom, copyFrom, copyTo, copyTo, endTag, getActionURL, getButtonAlign, getButtonList, getButtonStyle, getColumns, getControlSizeEst, getDefaultFieldSize, getEnctype, getError, getErrorFields, getErrorsAlign, getErrorsPosition, getErrorsStyle, getField, getFieldList, getFields, getFieldStyle, getFieldValue, getFieldWidths, getHeadElements, getJavaScriptValidation, getLabelAlign, getLabelsPosition, getLabelStyle, getMethod, getState, getTag, getValidate, hasPostError, insert, isDisabled, isFormSubmission, isJavaScriptValidation, isReadonly, isValid, onDestroy, onProcess, onSubmitCheck, onSubmitCheck, onSubmitCheck, performSubmitCheck, remove, removeField, removeFields, removeState, renderButtons, renderControls, renderErrors, renderFields, renderFocusJavaScript, renderHeader, renderTagEnd, renderValidationJavaScript, replace, restoreState, saveState, setActionURL, setButtonAlign, setButtonStyle, setColumns, setDefaultFieldSize, setDisabled, setEnctype, setError, setErrorsAlign, setErrorsPosition, setErrorsStyle, setFieldStyle, setJavaScriptValidation, setLabelAlign, setLabelsPosition, setLabelStyle, setListener, setMethod, setName, setReadonly, setState, setValidate, startTag, validate, validateFileUpload
 
Methods inherited from class org.apache.click.control.AbstractContainer
contains, getControl, getControlMap, getControls, hasControls, onInit, onRender, renderTagEnd, toString
 
Methods inherited from class org.apache.click.control.AbstractControl
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getHtmlImports, getId, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasBehaviors, hasStyles, isAjaxTarget, onDeploy, removeBehavior, removeStyleClass, setActionListener, setAttribute, setId, setParent, 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, getId, getMessages, getName, getParent, hasBehaviors, isAjaxTarget, onDeploy, setParent
 

Constructor Detail

HtmlForm

public HtmlForm(String name)
Create an html form with the given name.

Parameters:
name - the name of the form

HtmlForm

public HtmlForm()
Create an html form with no name.

Method Detail

add

public Field add(Field field,
                 int width)
This method is not supported and throws an UnsupportedOperationException if invoked.

Overrides:
add in class Form
Parameters:
field - the field to add to the form
width - the width of the field in table columns
Returns:
the field added to this form
Throws:
UnsupportedOperationException - if invoked

add

public Control add(Control control,
                   int width)
This method is not supported and throws an UnsupportedOperationException if invoked.

Overrides:
add in class Form
Parameters:
control - the control to add to the form
width - the width of the control in table columns
Returns:
the control added to this form
Throws:
UnsupportedOperationException - if invoked

render

public void render(HtmlStringBuffer buffer)
Render the HTML representation of the form and all its child controls to the specified buffer.

Specified by:
render in interface Control
Overrides:
render in class Form
Parameters:
buffer - the specified buffer to render the control's output to
See Also:
AbstractControl.render(org.apache.click.util.HtmlStringBuffer)

renderTagBegin

protected void renderTagBegin(String tagName,
                              HtmlStringBuffer buffer)
Overrides:
renderTagBegin in class AbstractControl
Parameters:
tagName - the name of the tag to render
buffer - the buffer to append the output to
See Also:
AbstractControl.renderTagBegin(java.lang.String, org.apache.click.util.HtmlStringBuffer)

renderContent

protected void renderContent(HtmlStringBuffer buffer)
Overrides:
renderContent in class AbstractContainer
Parameters:
buffer - the buffer to append the output to
See Also:
AbstractContainer.renderContent(org.apache.click.util.HtmlStringBuffer)

renderChildren

protected void renderChildren(HtmlStringBuffer buffer)
Overrides:
renderChildren in class AbstractContainer
Parameters:
buffer - the buffer to append the output to
See Also:
AbstractContainer.renderChildren(org.apache.click.util.HtmlStringBuffer)

getFormSizeEst

protected int getFormSizeEst(List<Field> formFields)
Overrides:
getFormSizeEst in class Form
Parameters:
formFields - the list of form fields
Returns:
the estimated rendered control size in characters
See Also:
AbstractControl.getControlSizeEst()