com.sencha.gxt.legacy.client.binding
Class FieldBinding

java.lang.Object
  extended by com.sencha.gxt.legacy.client.binding.FieldBinding

public class FieldBinding
extends 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

Constructor Summary
FieldBinding(Field field, 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<Object> getField()
          Returns the bound field.
 ModelData getModel()
          Returns the bound model instance.
 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.
 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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FieldBinding

public FieldBinding(Field field,
                    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<Object> getField()
Returns the bound field.

Returns:
the field

getModel

public ModelData getModel()
Returns the bound model instance.

Returns:
the model

getProperty

public 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.



Copyright © 2011. All Rights Reserved.