org.apache.tapestry.corelib.base
Class AbstractField

java.lang.Object
  extended by org.apache.tapestry.corelib.base.AbstractField
All Implemented Interfaces:
ClientElement, Field
Direct Known Subclasses:
AbstractTextField, Checkbox, DateField, Palette, Select, Submit, Upload

@SupportsInformalParameters
public abstract class AbstractField
extends Object
implements Field

Provides initialization of the clientId and elementName properties. In addition, adds the RenderInformals, RenderDisabled and DiscardBody mixins.


Field Summary
protected static FieldValidator NOOP_VALIDATOR
           
 
Constructor Summary
AbstractField()
           
 
Method Summary
protected  Binding createDefaultParameterBinding(String parameterName)
          Used by subclasses to create a default binding to a property of the container matching the component id.
protected  void decorateInsideField()
          Invoked from subclasses after they have written their tag and (where appropriate) their informal parameters and have allowed their Validator to write markup as well.
 String getClientId()
          Returns a unique id for the element.
 String getControlName()
          Returns the value used as the name attribute of the rendered element.
 String getLabel()
          Returns a user presentable (localized) label for the field, which may be used inside <label> elements on the client, and inside client or server-side validation error messages.
 boolean isDisabled()
          Returns true if the field is disabled; A disabled field will render a disabled attribute so that it is non-responsive on the client (at least, until its disabled status is changed on the client using JavaScript).
 boolean isRequired()
          Returns false; most components do not support declarative validation.
protected abstract  void processSubmission(String elementName)
          Method implemented by subclasses to actually do the work of processing the submission of the form.
protected  void setDecorator(ValidationDecorator decorator)
           
protected  void setFormSupport(FormSupport formSupport)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOOP_VALIDATOR

protected static final FieldValidator NOOP_VALIDATOR
Constructor Detail

AbstractField

public AbstractField()
Method Detail

getLabel

public final String getLabel()
Description copied from interface: Field
Returns a user presentable (localized) label for the field, which may be used inside <label> elements on the client, and inside client or server-side validation error messages.

Specified by:
getLabel in interface Field
Returns:
the label
See Also:
Label

getClientId

public final String getClientId()
Description copied from interface: ClientElement
Returns a unique id for the element. This value will be unique for any given rendering of a page. This value is intended for use as the id attribute of the client-side element, and will be used with any DHTML/Ajax related JavaScript.

Specified by:
getClientId in interface ClientElement

getControlName

public final String getControlName()
Description copied from interface: Field
Returns the value used as the name attribute of the rendered element. This value will be unique within an enclosing form, even if the same component renders multiple times.

Specified by:
getControlName in interface Field
See Also:
FormSupport.allocateControlName(String)

isDisabled

public final boolean isDisabled()
Description copied from interface: Field
Returns true if the field is disabled; A disabled field will render a disabled attribute so that it is non-responsive on the client (at least, until its disabled status is changed on the client using JavaScript). A disabled field will ignore any value passed up in a form submit request. Care must be taken if the disabled status of a field can change between the time the field is rendered and the time the enclosing form is submitted.

Specified by:
isDisabled in interface Field

createDefaultParameterBinding

protected final Binding createDefaultParameterBinding(String parameterName)
Used by subclasses to create a default binding to a property of the container matching the component id.

Returns:
a binding to the property, or null if the container does not have a corresponding property

processSubmission

protected abstract void processSubmission(String elementName)
Method implemented by subclasses to actually do the work of processing the submission of the form. The element's elementName property will already have been set. This method is only invoked if the field is not disabled.

Parameters:
elementName - the name of the element (used to find the correct parameter in the request)

decorateInsideField

protected final void decorateInsideField()
Invoked from subclasses after they have written their tag and (where appropriate) their informal parameters and have allowed their Validator to write markup as well.


setDecorator

protected final void setDecorator(ValidationDecorator decorator)

setFormSupport

protected final void setFormSupport(FormSupport formSupport)

isRequired

public boolean isRequired()
Returns false; most components do not support declarative validation.

Specified by:
isRequired in interface Field
Returns:
true if a non-blank value is required for the field


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.