com.sencha.gxt.data.shared
Class Store.Record

java.lang.Object
  extended by com.sencha.gxt.data.shared.Store.Record
Enclosing class:
Store<M>

public class Store.Record
extends java.lang.Object

Records wrap model instances and provide specialized editing features, including modification tracking and editing capabilities.


Constructor Summary
Store.Record(M model)
          Creates a new record that wraps the given model.
 
Method Summary
<V> void
addChange(ValueProvider<? super M,V> property, V value)
          Adds a change to the data in this Record.
 void commit(boolean fireEvent)
          Commits the changes to the model tracked by this record.
<V> Store.Change<M,V>
getChange(ValueProvider<? super M,V> property)
          Gets the current Change object applied to that property, if any.
 java.util.Collection<Store.Change<M,?>> getChanges()
          Returns all changes.
 M getModel()
          Returns the wrapped model instance.
<V> V
getValue(ValueProvider<? super M,V> property)
          Gets the current value of this property in the record, whether it is saved or not.
 boolean isDirty()
          Returns true if the record has uncommitted changes.
 void revert()
          Rejects all changes made to the Record since either creation, or the last commit operation.
 void revert(ValueProvider<? super M,?> property)
          Rejects a single change made to the Record since its creation, or since the last commit operation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Store.Record

public Store.Record(M model)
Creates a new record that wraps the given model.

Parameters:
model - the model to be wrapped by this record
Method Detail

addChange

public <V> void addChange(ValueProvider<? super M,V> property,
                          V value)
Adds a change to the data in this Record. If auto commit is enabled, the change will be made directly to the model, else the change will be queued up until commit() is called.

Type Parameters:
V - the value type (for the changed property in the model)
Parameters:
property - the property to change
value - the changed value

commit

public void commit(boolean fireEvent)
Commits the changes to the model tracked by this record.


getChange

public <V> Store.Change<M,V> getChange(ValueProvider<? super M,V> property)
Gets the current Change object applied to that property, if any.

Type Parameters:
V - the value type (for the changed property in the model)
Parameters:
property - the changed property
Returns:
a Change object, or null if the value is the default

getChanges

public java.util.Collection<Store.Change<M,?>> getChanges()
Returns all changes.

Returns:
collection of the changes

getModel

public M getModel()
Returns the wrapped model instance.

Returns:
the model

getValue

public <V> V getValue(ValueProvider<? super M,V> property)
Gets the current value of this property in the record, whether it is saved or not. The value on the model in this record can be obtained by calling property.getValue(record.getModel())

Type Parameters:
V - the value type (for the property in the model)
Parameters:
property - the property containing the value to get
Returns:
current value of this property

isDirty

public boolean isDirty()
Returns true if the record has uncommitted changes.

Returns:
the dirty state

revert

public void revert(ValueProvider<? super M,?> property)
Rejects a single change made to the Record since its creation, or since the last commit operation. Fires a StoreUpdateEvent if a change is made.

Parameters:
property - the property of the model to revert

revert

public void revert()
Rejects all changes made to the Record since either creation, or the last commit operation. Modified fields are reverted to their original values.



Copyright © 2012. All Rights Reserved.