com.gwtext.client.data
Class Record

java.lang.Object
  extended by com.gwtext.client.core.JsObject
      extended by com.gwtext.client.data.Record

public class Record
extends JsObject

Instances of this class encapsulate both record definition information, and record value information for use in Store objects, or any code which needs to access Records cached in a Store object.

See Also:
Store

Nested Class Summary
static class Record.Operation
           
 
Field Summary
static Record.Operation COMMIT
           
static Record.Operation EDIT
           
static Record.Operation REJECT
           
 
Fields inherited from class com.gwtext.client.core.JsObject
jsObj
 
Constructor Summary
Record(com.google.gwt.core.client.JavaScriptObject jsObj)
          This constructor is for internal / special uses only.
 
Method Summary
 void beginEdit()
          Begin an edit.
 void cancelEdit()
          Cancels all changes made in the current edit operation.
 void commit()
          Usually called by the Store which owns the Record.
 void commit(boolean silent)
          Usually called by the Store which owns the Record.
 Record copy()
          Creates a copy of this record.
 Record copy(java.lang.String id)
          Creates a copy of this record.
 void endEdit()
          End an edit.
 boolean getAsBoolean(java.lang.String field)
          Returns the Records value as a boolean value.
 java.util.Date getAsDate(java.lang.String field)
          Return the fields value as a Date.
 double getAsDouble(java.lang.String field)
          Returns the Records value as a double.
 float getAsFloat(java.lang.String field)
          Returns the Records value as a float.
 int getAsInteger(java.lang.String field)
          Returns the Records value as an integer.
 java.lang.Object getAsObject(java.lang.String field)
          Return the field value as Object.
 java.lang.String getAsString(java.lang.String field)
          Return the field value as String.
 com.google.gwt.core.client.JavaScriptObject getDataAsJsObject()
          Returns the underlying native data representation like a Json or XML node.
 java.lang.Object getDataAsObject()
          Returns the field value as an Object.
 java.lang.String[] getFields()
           
 java.lang.String getId()
          Returns the ID of the record or null if not defined.
 java.lang.String[] getModifiedFields()
          Return the names of the fields that are modified in this record.
 boolean isDirty()
          The Records modified state.
 boolean isEmpty(java.lang.String fieldName)
          Return true if the specified field is null(or undefined) or an empty string
 boolean isModified(java.lang.String fieldName)
          Return true if specified field has been modified.
 boolean isNull(java.lang.String fieldName)
          Return true if specified field is null (or undefined)
 void reject()
          Usually called by the Store which owns the Record.
 void reject(boolean silent)
          Usually called by the Store which owns the Record.
 void set(java.lang.String field, boolean value)
          Sets the fields value.
 void set(java.lang.String field, java.util.Date value)
          Sets the fields value.
 void set(java.lang.String field, double value)
          Sets the fields value.
 void set(java.lang.String field, float value)
          Sets the fields value.
 void set(java.lang.String field, int value)
          Sets the fields value.
 void set(java.lang.String field, java.lang.Object value)
          Sets the fields Object value.
 void set(java.lang.String field, java.lang.String value)
          Sets the fields value.
 void setId(java.lang.String id)
          Set the Record's ID.
 
Methods inherited from class com.gwtext.client.core.JsObject
getJsObj, getProperties, isCreated, setJsObj
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EDIT

public static Record.Operation EDIT

REJECT

public static Record.Operation REJECT

COMMIT

public static Record.Operation COMMIT
Constructor Detail

Record

public Record(com.google.gwt.core.client.JavaScriptObject jsObj)
This constructor is for internal / special uses only. Do not use this to create a new Record instance. You should use the factory method RecordDef.createRecord(String, Object[]) to create new Records.

Parameters:
jsObj - a native record object.
Method Detail

getId

public java.lang.String getId()
Returns the ID of the record or null if not defined.

Returns:
ID of the record

isDirty

public boolean isDirty()
The Records modified state.

Returns:
true if this record has been modified

beginEdit

public void beginEdit()
Begin an edit. While in edit mode, no events are relayed to the containing store.


cancelEdit

public void cancelEdit()
Cancels all changes made in the current edit operation.


copy

public Record copy()
Creates a copy of this record.

Returns:
copy of this Record

copy

public Record copy(java.lang.String id)
Creates a copy of this record.

Parameters:
id - a new record id if you don't want to use this record's id
Returns:
copy of this Record

commit

public void commit()
Usually called by the Store which owns the Record. Commits all changes made to the Record since either creation, or the last commit operation. Developers should subscribe to StoreListener.onUpdate(Store, Record, com.gwtext.client.data.Record.Operation) event to have their code notified of commit operations.


commit

public void commit(boolean silent)
Usually called by the Store which owns the Record. Commits all changes made to the Record since either creation, or the last commit operation. Developers should subscribe to StoreListener.onUpdate(Store, Record, com.gwtext.client.data.Record.Operation) event to have their code notified of commit operations.

Parameters:
silent - true to skip notification of the owning store of the change (defaults to false)

endEdit

public void endEdit()
End an edit. If any data was modified, the containing store is notified.


getAsString

public java.lang.String getAsString(java.lang.String field)
Return the field value as String.

Parameters:
field - the field name
Returns:
the field value

getAsObject

public java.lang.Object getAsObject(java.lang.String field)
Return the field value as Object.

Parameters:
field - the field name
Returns:
the filed value

isModified

public boolean isModified(java.lang.String fieldName)
Return true if specified field has been modified.

Parameters:
fieldName - the field name
Returns:
true if modified

isNull

public boolean isNull(java.lang.String fieldName)
Return true if specified field is null (or undefined)

Parameters:
fieldName - the field name
Returns:
true if null or undefined

isEmpty

public boolean isEmpty(java.lang.String fieldName)
Return true if the specified field is null(or undefined) or an empty string

Parameters:
fieldName - the field name
Returns:
true if empty

set

public void set(java.lang.String field,
                java.lang.Object value)
Sets the fields Object value.

Parameters:
field - the field name
value - the fiedl value

set

public void set(java.lang.String field,
                java.lang.String value)
Sets the fields value.

Parameters:
field - the field name
value - the field value

getAsInteger

public int getAsInteger(java.lang.String field)
Returns the Records value as an integer.

Parameters:
field - the field name
Returns:
the field value

set

public void set(java.lang.String field,
                int value)
Sets the fields value.

Parameters:
field - the field name
value - the field value

getAsFloat

public float getAsFloat(java.lang.String field)
Returns the Records value as a float.

Parameters:
field - the field name
Returns:
the field value

set

public void set(java.lang.String field,
                float value)
Sets the fields value.

Parameters:
field - the field name
value - the field value

getAsDouble

public double getAsDouble(java.lang.String field)
Returns the Records value as a double.

Parameters:
field - the field name
Returns:
the field value

set

public void set(java.lang.String field,
                double value)
Sets the fields value.

Parameters:
field - the field name
value - the field value

getAsBoolean

public boolean getAsBoolean(java.lang.String field)
Returns the Records value as a boolean value. If val is null, undefined, false, -0, +0, NaN, or an empty string (""), this method returns false, otherwise it returns true for all other numbers and strings.

Parameters:
field - the field name
Returns:
the field value

set

public void set(java.lang.String field,
                boolean value)
Sets the fields value.

Parameters:
field - the field name
value - the field value

setId

public void setId(java.lang.String id)
Set the Record's ID.

Parameters:
id - the record ID

getAsDate

public java.util.Date getAsDate(java.lang.String field)
Return the fields value as a Date.

Parameters:
field - the field name
Returns:
the field value

set

public void set(java.lang.String field,
                java.util.Date value)
Sets the fields value.

Parameters:
field - the field name
value - the field value

getModifiedFields

public java.lang.String[] getModifiedFields()
Return the names of the fields that are modified in this record.

Returns:
modified field names. Returns an empty array if no fields are modified.

getFields

public java.lang.String[] getFields()

reject

public void reject()
Usually called by the Store which owns the Record. Rejects all changes made to the Record since either creation, or the last commit operation. Modified fields are reverted to their original values. Developers should subscribe to the StoreListener.onUpdate(Store, Record, com.gwtext.client.data.Record.Operation) event to have their code notified of reject operations.


reject

public void reject(boolean silent)
Usually called by the Store which owns the Record. Rejects all changes made to the Record since either creation, or the last commit operation. Modified fields are reverted to their original values. Developers should subscribe to the StoreListener.onUpdate(Store, Record, com.gwtext.client.data.Record.Operation) event to have their code notified of reject operations.

Parameters:
silent - true to skip notification of the owning store of the change (defaults to false)

getDataAsObject

public java.lang.Object getDataAsObject()
Returns the field value as an Object.

Returns:
the data object

getDataAsJsObject

public com.google.gwt.core.client.JavaScriptObject getDataAsJsObject()
Returns the underlying native data representation like a Json or XML node.

Returns:
data as native object