net.sf.echobinding.binding
Interface PropertyAdapter

All Known Implementing Classes:
AbstractPropertyAdapter, OgnlPropertyAdapter

public interface PropertyAdapter

A PropertyAdapter is an adapter for a single bean property or a collection of beans. Through a PropertyAdapter you can retrieve and set the value of properties in a uniform way. The PropertyAdapter interface defines the protocol for accessing, manipulating and validating beans.

See Also:
BindingContext, Format, Decorator, ValidationHandler

Method Summary
 PropertyAdapter addValidator(Validator validator)
          Adds a validator to the list of validators.
 Decorator getDecorator()
          Returns the decorator.
 Format getFormat()
          Sets the format to be used by the getValue() method.
 java.lang.String getId()
          Returns the identifier of the adapter.
 java.lang.String getLabel()
          Returns the label for the adapter.
 BindingContext getSubContext()
          Returns the sub context.
 ValidationHandler getValidationHandler()
          Returns the validation handler.
 java.lang.Object getValue(java.lang.Object bean)
          Returns the value of the wrapped bean property.
 PropertyAdapter newInstance()
          Creates a new adapter instance.
 PropertyAdapter setDecorator(Decorator decorator)
          Sets the decorator for this adapter.
 PropertyAdapter setFormat(Format format)
          Sets the format to be used by the getValue() method.
 PropertyAdapter setId(java.lang.String id)
          Sets the identifier for the adapter.
 PropertyAdapter setLabel(java.lang.String labelName)
          Sets the label.
 PropertyAdapter setSubContext(BindingContext context)
          Sets the sub context.
 PropertyAdapter setValidationHandler(ValidationHandler handler)
          Sets the validation handler.
 PropertyAdapter setValidators(java.util.Set<Validator> validators)
          Sets the validators.
 void setValue(java.lang.Object bean, java.lang.Object value)
          Sets the value of the wrapped bean property.
 ValidationReport validate(java.lang.Object bean, java.lang.Object value)
          Checks if the given value is valid for the specified bean.
 

Method Detail

setId

PropertyAdapter setId(java.lang.String id)
Sets the identifier for the adapter. Generally you won't have to set the adapter id explicitly. Whenever you add/get an adapter to/from the binding context the there specified adapter id will be used as identfier.

Parameters:
id - the id
Returns:
the adapter

getId

java.lang.String getId()
Returns the identifier of the adapter.

Returns:
the adapter's id

setValue

void setValue(java.lang.Object bean,
              java.lang.Object value)
              throws BindingException
Sets the value of the wrapped bean property.

Parameters:
value - The value to set
bean - The bean
Throws:
BindingException - If the value cannot be set (eg. if the adapter is not applicable for the bean/property)

getValue

java.lang.Object getValue(java.lang.Object bean)
                          throws BindingException
Returns the value of the wrapped bean property.

Parameters:
bean - the bean
Returns:
the value
Throws:
BindingException - If the value cannot be retrieved (eg. if the adapter is not applicable for the bean/property)

validate

ValidationReport validate(java.lang.Object bean,
                          java.lang.Object value)
Checks if the given value is valid for the specified bean. Returns a ValidationReport which tells you if the value is valid (ValidationReport.isValid()). The ValidationReport may also contain the error message (ValidationReport.getMessage()).

Parameters:
value - the value to validate
bean - the bean
Returns:
the validation report
See Also:
ValidationReport

setValidators

PropertyAdapter setValidators(java.util.Set<Validator> validators)
Sets the validators. Validators are used to validate bean input. Each added Validator will be consulted when a bean input is checked by the validate(Obejct bean, Obejct value) method.

Parameters:
validators - the validators
Returns:
the property adapter
See Also:
Validator

addValidator

PropertyAdapter addValidator(Validator validator)
Adds a validator to the list of validators.

Parameters:
validator -
Returns:
See Also:
Validator

setFormat

PropertyAdapter setFormat(Format format)
Sets the format to be used by the getValue() method.

Parameters:
format - the format
Returns:
the adapter

getFormat

Format getFormat()
Sets the format to be used by the getValue() method.

Parameters:
format - *
Returns:
the adapter

setDecorator

PropertyAdapter setDecorator(Decorator decorator)
Sets the decorator for this adapter. A Decorator will be used in list components (SelectField, ListBox) to decorate the items in the list.

Parameters:
decorator - the decorator
Returns:
the property adapter

getDecorator

Decorator getDecorator()
Returns the decorator.

Returns:
the decorator

setLabel

PropertyAdapter setLabel(java.lang.String labelName)
Sets the label. Labels are user in data bound tables for the column header names.

Parameters:
labelName - The label to set.
Returns:
the property adapter

getLabel

java.lang.String getLabel()
Returns the label for the adapter.

Returns:
the label

setSubContext

PropertyAdapter setSubContext(BindingContext context)
Sets the sub context. In case your adapter wraps another bean or a collection of beans you may specify a sub context for this bean. Sub contexts are often used in data bound tables to resolve relationships between entities (e.g. one-to-many associations).

Parameters:
context - The context to set
Returns:
the property adapter

getSubContext

BindingContext getSubContext()
Returns the sub context.

Returns:
the sub context

newInstance

PropertyAdapter newInstance()
Creates a new adapter instance. Clones the adapter. Will be used by the binding context to create child contexts.

Returns:
the property adapter

setValidationHandler

PropertyAdapter setValidationHandler(ValidationHandler handler)
Sets the validation handler. A ValidationHanlder is used to report (validation) errors to the user.

Parameters:
handler - The validation handler
Returns:
the property adapter

getValidationHandler

ValidationHandler getValidationHandler()
Returns the validation handler.

Returns:
the validation handler


Copyright © 2007. All Rights Reserved.