wheel.components
Class Form

java.lang.Object
  extended by wheel.components.Component
      extended by wheel.components.RenderableComponent
          extended by wheel.components.Form
All Implemented Interfaces:
IBuildableComponent, IContainer

public class Form
extends RenderableComponent
implements IContainer, IBuildableComponent

Represents an HTML form. Only complex components (instances of StandaloneComponent) can contain Forms.

Author:
Henri Frilund

Nested Class Summary
static class Form.Method
           
 
Method Summary
 void _clear()
          Inteded for internal use.
 boolean _isBuilt()
           
 void _render(org.xmlpull.v1.XmlSerializer serializer)
          Default implementation.
 void _renderActions(org.xmlpull.v1.XmlSerializer serializer)
           
 void _setBuilt(boolean built)
           
 Form addFormValidationError(java.lang.String message)
           
 Form addFormValidationRule(java.lang.String elExpression, java.lang.String message)
          Adds a validation rule for the whole form.
 void buildComponent()
          Builds the component preparing it for rendering.
protected  java.lang.String defaultDomEvent()
           
 java.lang.String defaultTagName()
          Subclasses must implement this.
 FormElement field(java.lang.String fieldName)
          Finds a FormElement from this Form with the given name.
 ActionExpression getAction()
           
 java.util.Set<FormElement> getFormElements()
          Returns all FormElements that this Form contains.
 java.util.List<FormElement> getInvalidFields()
          Returns a list of fields in this form that are invalid.
 java.util.List<ValidationError> getValidationErrors()
          Lists all validation errors that were caused by erroneous evaluations of formValidationRules, added with addFormValidationRule().
 Form id(java.lang.String componentId)
          Changes the componentId.
 boolean isFormValid()
          Returns true if the form is valid.
 boolean isValid(java.lang.String componentId)
          Returns false if the form containing complex component is rewinding and a form element with the given componentId is found and the form element is not valid.
 void postBuild()
          Called after buildComponent().
 void preBuild()
          Called before buildComponent().
 Form renderHint(java.lang.CharSequence renderHint)
          Adds a rendering hint to this component.
 void setMethod(Form.Method method)
          Sets the HTTP METHOD the form should use when submitted.
 
Methods inherited from class wheel.components.RenderableComponent
_classReferenceFromHints, _getRenderAfterMe, _getRenderBeforeMe, _renderClassReferenceFromHints, _renderTagStart, _renderXhtmlAttributes, addRenderAfter, addRenderBefore, config, getTagName, renderComponent, toString
 
Methods inherited from class wheel.components.Component
_applyFormat, _getAction, _getActions, _getChildren, _getForm, _getRenderableChildren, _getRenderHints, _getTopLevelComponent, _getVisibleForm, _getXhtmlAttributes, _isGeneratedId, _setComponentId, _setGeneratedId, _wrapComponentId, a, a, abbr, abbr, acronym, acronym, action, actionBinding, actionBinding, add, addFirst, address, address, afterAdd, area, attribute, attributes, b, b, base, bdo, big, big, blockquote, br, button, caption, checkbox, checkboxGroup, cite, cite, clasS, col, colgroup, create, dateInput, dd, dd, del, del, dfn, dfn, div, dl, dt, dt, el, em, em, encode, entity, equals, eval, fieldset, fileInput, fileInput, find, findAll, form, form, frame, frameset, get, getComponentId, getComponentName, getComponents, getEngine, getPage, getParent, h1, h1, h2, h2, h3, h3, h4, h4, h5, h5, h6, h6, hashCode, head, hidden, hr, htmlText, i, i, iframe, img, ins, ins, kbd, kdb, label, label, legend, legend, li, li, link, link, map, message, message, meta, multiSelect, nbsp, noframes, noscript, numberInput, numberInput, object, ol, p, p, param, placeholder, pre, pre, q, q, radio, radioGroup, rawText, remove, remove, requestFocus, s, s, samp, samp, script, select, selectModel, small, small, span, span, strike, strike, strong, strong, style, sub, sub, submit, sup, sup, table, tbody, td, text, textarea, textInput, tfoot, th, thead, title, tr, u, u, ul, up, up, var, var, wBlock, wrapSelf
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

buildComponent

public void buildComponent()
Description copied from interface: IBuildableComponent
Builds the component preparing it for rendering.

Specified by:
buildComponent in interface IBuildableComponent

preBuild

public void preBuild()
Description copied from interface: IBuildableComponent
Called before buildComponent().

Specified by:
preBuild in interface IBuildableComponent

postBuild

public void postBuild()
Description copied from interface: IBuildableComponent
Called after buildComponent(). Useful for cleaning up resources after buildComponent() and possibly doing some modifications on the component tree before rendering.

Specified by:
postBuild in interface IBuildableComponent

_isBuilt

public boolean _isBuilt()
Specified by:
_isBuilt in interface IBuildableComponent

_setBuilt

public void _setBuilt(boolean built)
Specified by:
_setBuilt in interface IBuildableComponent

setMethod

public void setMethod(Form.Method method)
Sets the HTTP METHOD the form should use when submitted.

Parameters:
method -

defaultTagName

public java.lang.String defaultTagName()
Description copied from class: RenderableComponent
Subclasses must implement this. If no xhtml tagname can be resolved from rendering hints, will default to value returned by this method.

Specified by:
defaultTagName in class RenderableComponent
Returns:

getAction

public ActionExpression getAction()

getInvalidFields

public java.util.List<FormElement> getInvalidFields()
Returns a list of fields in this form that are invalid. This information is available only when rewinding.

Returns:

isValid

public boolean isValid(java.lang.String componentId)
Returns false if the form containing complex component is rewinding and a form element with the given componentId is found and the form element is not valid.

Parameters:
componentId -
Returns:

isFormValid

public boolean isFormValid()
Returns true if the form is valid.

Returns:

getValidationErrors

public java.util.List<ValidationError> getValidationErrors()
Lists all validation errors that were caused by erroneous evaluations of formValidationRules, added with addFormValidationRule().

Returns:

_clear

public void _clear()
Description copied from class: Component
Inteded for internal use. Clears all attributes and child components.

Overrides:
_clear in class RenderableComponent

field

public FormElement field(java.lang.String fieldName)
Finds a FormElement from this Form with the given name.

Parameters:
fieldName -
Returns:
Throws:
WheelException - if no component was found with the given componentId.

getFormElements

public java.util.Set<FormElement> getFormElements()
Returns all FormElements that this Form contains.

Returns:

id

public Form id(java.lang.String componentId)
Description copied from class: Component
Changes the componentId.

Overrides:
id in class Component
Parameters:
componentId - New component id.
Returns:

renderHint

public Form renderHint(java.lang.CharSequence renderHint)
Description copied from class: Component
Adds a rendering hint to this component. A rendering hint can be either a css class reference or a xhtml specification tag name. Many rendering hints can be given in one input string. Example: "h1 error" will cause the component to render as <h1 class="error">. Note that the html tag name doesn't have to be first.

Overrides:
renderHint in class Component
Returns:
Will return the component itself to enable method chaining.

addFormValidationRule

public Form addFormValidationRule(java.lang.String elExpression,
                                  java.lang.String message)
Adds a validation rule for the whole form. These validation are run after all fields are set (and validated). All form elements are available in the el-expression.

Parameters:
elExpression -
message -
Returns:

addFormValidationError

public Form addFormValidationError(java.lang.String message)

_render

public void _render(org.xmlpull.v1.XmlSerializer serializer)
             throws java.io.IOException
Description copied from class: RenderableComponent
Default implementation. Handles render before/after logic. Will first figure out the xhtml tag to use from rendering hints, then delegates to renderComponent(). Subclasses should override renderComponent() rather than this method.

Overrides:
_render in class RenderableComponent
Throws:
java.io.IOException

_renderActions

public void _renderActions(org.xmlpull.v1.XmlSerializer serializer)
                    throws java.io.IOException
Overrides:
_renderActions in class RenderableComponent
Throws:
java.io.IOException

defaultDomEvent

protected java.lang.String defaultDomEvent()
Overrides:
defaultDomEvent in class RenderableComponent


Copyright © 2007-2008. All Rights Reserved.