com.extjs.gxt.ui.client.binding
Class FieldBinding

java.lang.Object
  extended by com.extjs.gxt.ui.client.binding.FieldBinding
Direct Known Subclasses:
SimpleComboBoxFieldBinding, TimeFieldBinding

public class FieldBinding
extends java.lang.Object

A two-way binding between a ModelData and Field instance. The binding will be 1-way when the bound model does not support change events.

See Also:
ModelData, Field

Field Summary
protected  Field field
           
protected  ModelData model
           
protected  java.lang.String property
           
protected  Store store
           
 
Constructor Summary
FieldBinding(Field field, java.lang.String property)
          Creates a new binding instance.
 
Method Summary
 void bind(ModelData model)
          Binds the model and field.
 Converter getConverter()
          Returns the bindings converter.
 Field<java.lang.Object> getField()
          Returns the bound field.
 ModelData getModel()
          Returns the bound model instance.
 java.lang.String getProperty()
          Returns the model's bound property name.
 Store getStore()
          Returns the binding's store.
 boolean isUpdateOriginalValue()
          Returns true if the field's original value is updated when the field is bound.
protected  java.lang.Object onConvertFieldValue(java.lang.Object value)
           
protected  java.lang.Object onConvertModelValue(java.lang.Object value)
           
protected  void onFieldChange(FieldEvent e)
           
protected  void onModelChange(PropertyChangeEvent event)
           
 void setConverter(Converter converter)
          Sets the converter which is used to translate data types when updating either the field or model.
 void setStore(Store<? extends ModelData> store)
          Sets the store for the binding.
 void setUpdateOriginalValue(boolean updateOriginalValue)
          True to update the field's original value when bound (defaults to false).
 void unbind()
          Unbinds the model and field by removing all listeners.
 void updateField()
          Updates the field's value with the model value.
 void updateField(boolean updateOriginalValue)
          Updates the field's value and original value with the model value.
 void updateModel()
          Updates the model's value with the field value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

field

protected Field field

model

protected ModelData model

property

protected java.lang.String property

store

protected Store store
Constructor Detail

FieldBinding

public FieldBinding(Field field,
                    java.lang.String property)
Creates a new binding instance.

Parameters:
field - the bound field for the binding
Method Detail

bind

public void bind(ModelData model)
Binds the model and field. This method also updates the fields original value which controls the dirty state of the field.

Parameters:
model - the model to be bound

getConverter

public Converter getConverter()
Returns the bindings converter.

Returns:
the converter

getField

public Field<java.lang.Object> getField()
Returns the bound field.

Returns:
the field

getModel

public ModelData getModel()
Returns the bound model instance.

Returns:
the model

getProperty

public java.lang.String getProperty()
Returns the model's bound property name.

Returns:
the property name

getStore

public Store getStore()
Returns the binding's store.

Returns:
the store or null

isUpdateOriginalValue

public boolean isUpdateOriginalValue()
Returns true if the field's original value is updated when the field is bound.

Returns:
true if original value is updated

setConverter

public void setConverter(Converter converter)
Sets the converter which is used to translate data types when updating either the field or model.

Parameters:
converter - the converter

setStore

public void setStore(Store<? extends ModelData> store)
Sets the store for the binding. When a store is specified edits are done via Records instances obtained from the Store.

Parameters:
store - the store

setUpdateOriginalValue

public void setUpdateOriginalValue(boolean updateOriginalValue)
True to update the field's original value when bound (defaults to false).

Parameters:
updateOriginalValue - true to update the original value

unbind

public void unbind()
Unbinds the model and field by removing all listeners.


updateField

public void updateField()
Updates the field's value with the model value.


updateField

public void updateField(boolean updateOriginalValue)
Updates the field's value and original value with the model value. Updating the original value will reset the field to a non-dirty state.

Parameters:
updateOriginalValue - true to update the original value

updateModel

public void updateModel()
Updates the model's value with the field value.


onConvertFieldValue

protected java.lang.Object onConvertFieldValue(java.lang.Object value)

onConvertModelValue

protected java.lang.Object onConvertModelValue(java.lang.Object value)

onFieldChange

protected void onFieldChange(FieldEvent e)

onModelChange

protected void onModelChange(PropertyChangeEvent event)