com.smartgwt.client.data
Class SimpleType

java.lang.Object
  extended by com.smartgwt.client.core.BaseClass
      extended by com.smartgwt.client.data.SimpleType

public class SimpleType
extends BaseClass

An atomic type such as a string or number, that is generally stored, displayed and manipulated as a single value.

SimpleTypes can be created at any time, and subsequently referred to as a 'field type' in DataSource and DataBoundComponent. This allows you to define 'validation', com.smartgwt.client.data.SimpleType#normalDisplayFormatter and 'editing' behaviors for a type to be reused across all DataBoundComponent.

Note that the term "simpleType" is used in the same sense as in http://www.w3.org/TR/xmlschema-0/, and XMLTools.loadXMLSchema(java.lang.String, com.smartgwt.client.data.XSDLoadCallback) will create new SimpleType definitions.

An ${isc.DocUtils.linkForExampleId('customSimpleType', 'example')} is here.


Field Summary
 
Fields inherited from class com.smartgwt.client.core.BaseClass
config, id, scClassName
 
Constructor Summary
SimpleType(JavaScriptObject jsObj)
           
SimpleType(String name, FieldType inheritsFrom)
          Create a new simple type.
SimpleType(String name, SimpleType inheritsFrom)
          Create a new simple type.
 
Method Summary
 JavaScriptObject create()
           
 String getInheritsFrom()
          Name of another SimpleType from which this type should inherit.
 String getName()
          Name of the type, used to refer to the type from 'field.name'.
static SimpleType getOrCreateRef(JavaScriptObject jsObj)
           
static SimpleType getType(String typeName)
          Retrieve a simpleType definition by type name
 void setEditorType(FormItem editorType)
          Classname of the FormItem that should be the default for editing values of this type (eg "SelectItem").
 void setInheritsFrom(FieldType inheritsFrom)
          Name of another SimpleType from which this type should inherit.
 void setInheritsFrom(String inheritsFrom)
          Name of another SimpleType from which this type should inherit.
 void setName(String name)
          Name of the type, used to refer to the type from 'field.name'.
 void setValidators(Validator... validators)
          Validators to apply to value of this type.
 void setValidOperators(OperatorId... operators)
          Set of search operators valid for this type.
 void setValueMap(Map valueMap)
          List of legal values for this type, like valueMap.
 void setValueMap(String... valueMap)
          List of legal values for this type, like valueMap.
 
Methods inherited from class com.smartgwt.client.core.BaseClass
destroy, doAddHandler, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsString, getConfig, getHandlerCount, getID, getJsObj, getOrCreateJsObj, getRef, isCreated, onInit, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setID, setProperty, setProperty, setProperty, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleType

public SimpleType(JavaScriptObject jsObj)

SimpleType

public SimpleType(String name,
                  FieldType inheritsFrom)
Create a new simple type.

Parameters:
name - the name of the simple type
inheritsFrom - the type it inherits from

SimpleType

public SimpleType(String name,
                  SimpleType inheritsFrom)
Create a new simple type.

Parameters:
name - the name of the simple type
inheritsFrom - the type it inherits from
Method Detail

getOrCreateRef

public static SimpleType getOrCreateRef(JavaScriptObject jsObj)

create

public JavaScriptObject create()
Specified by:
create in class BaseClass

setName

public void setName(String name)
             throws IllegalStateException
Name of the type, used to refer to the type from 'field.name'.

Parameters:
name - name Default value is null
Throws:
IllegalStateException - this property cannot be changed after the underlying component has been created

getName

public String getName()
Name of the type, used to refer to the type from 'field.name'.

Returns:
String

setInheritsFrom

public void setInheritsFrom(String inheritsFrom)
                     throws IllegalStateException
Name of another SimpleType from which this type should inherit.

Validators, if any, will be combined. All other SimpleType properties default to the inherited type's value.

Parameters:
inheritsFrom - inheritsFrom Default value is null
Throws:
IllegalStateException - this property cannot be changed after the underlying component has been created

getInheritsFrom

public String getInheritsFrom()
Name of another SimpleType from which this type should inherit.

Validators, if any, will be combined. All other SimpleType properties default to the inherited type's value.

Returns:
String

getType

public static SimpleType getType(String typeName)
Retrieve a simpleType definition by type name

Parameters:
typeName - the name of the simpleType to return
Returns:
ssimple type object

setValidators

public void setValidators(Validator... validators)
                   throws IllegalStateException
Validators to apply to value of this type.

Parameters:
validators - validators Default value is null
Throws:
IllegalStateException - this property cannot be changed after the underlying component has been created

setValueMap

public void setValueMap(String... valueMap)
                 throws IllegalStateException
List of legal values for this type, like valueMap.

Parameters:
valueMap - valueMap Default value is null
Throws:
IllegalStateException - this property cannot be changed after the underlying component has been created

setValueMap

public void setValueMap(Map valueMap)
                 throws IllegalStateException
List of legal values for this type, like valueMap.

Parameters:
valueMap - valueMap Default value is null
Throws:
IllegalStateException - this property cannot be changed after the underlying component has been created

setEditorType

public void setEditorType(FormItem editorType)
                   throws IllegalStateException
Classname of the FormItem that should be the default for editing values of this type (eg "SelectItem").

You can create a simple custom FormItem by adding default icons that launch custom value picking dialogs (an example is in the QuickStart Guide, Chapter 9, Extending Smart GWT). By setting simpleType.editorType to the name of your custom FormItem, forms will automatically use the custom FormItem, as will grids performing canEdit.

Parameters:
editorType - editorType Default value is null
Throws:
IllegalStateException - this property cannot be changed after the underlying component has been created

setValidOperators

public void setValidOperators(OperatorId... operators)
                       throws IllegalStateException
Set of search operators valid for this type.

If not specified, the inheritsFrom type's operators will be used, finally defaulting to the default operators for the basic types (eg integer).

Parameters:
operators - validOperators Default value is null
Throws:
IllegalStateException - this property cannot be changed after the underlying component has been created

setInheritsFrom

public void setInheritsFrom(FieldType inheritsFrom)
                     throws IllegalStateException
Name of another SimpleType from which this type should inherit.

Validators, if any, will be combined. All other SimpleType properties default to the inherited type's value.

Parameters:
inheritsFrom - inheritsFrom Default value is null
Throws:
IllegalStateException - this property cannot be changed after the underlying component has been created