Class SimpleType
- All Implemented Interfaces:
HasHandlers
SimpleTypes can be created
at any time, and subsequently referred
to as a field type
in DataSources
and
DataBoundComponents
. This allows you to define
validation
, formatting
and editing
behaviors for a type to be reused across all
DataBoundComponents
.
The SimpleType class also allows data to be stored in some opaque format but treated as
simple atomic values as far as Smart GWT components are concerned by implementing
getAtomicValue()
and updateAtomicValue()
methods.
For example, if some record has a field value set to a javascript object with the
following properties:
{ stringValue:"A String", length: 9 }this value could be treated as a simple string by defining a SimpleType with
inheritsFrom
set to "text"
and a custom
getAtomicValue()
method that simply extracted the "stringValue"
attribute from the data object. DataBoundComponents would then display
the string value, and use it for sorting and other standard databinding features.
Note that the term "simpleType" is used in the same sense as in
XML Schema, and
XMLTools.loadXMLSchema()
will create new SimpleType definitions.
When using the Smart GWT Server, SimpleTypes can be defined server-side, and should be defined server-side if validators are going to be declared so that the server will enforce validation. To define server-side SimpleTypes using Component XML you should create file {typeName}.type.xml in the following format:
<SimpleType name="{typeName}" inheritsFrom="{otherSimpleType}" editorType="{FormItemClassName}"> <validators> <!-- validator definition just like DataSourceField --> </validators> </SimpleType>.. and place this file alongside your DataSource files (.ds.xml) files - in any of folders listed in
project.datasources
property in server.properties
.
SimpleTypes can be loaded via DataSourceLoader or loadDS JSP tags
and
should be loaded before the definitions of any DataSources that use them (so
generally put all SimpleType definitions first).
Define validators in the server-side type definition, for example:
<SimpleType name="countryCodeType" inheritsFrom="text"> <validators> <validator type="lengthRange" min="2" max="2" errorMessage="Length of country code should be equal to 2." /> <validator type="regexp" expression="[A-Z][A-Z]" errorMessage="CountryCode should have only uppercase letters." /> </validators> </SimpleType>
For client-side formatters, add these to the type definition after loading it from the server, for example:
SimpleType.getType("independenceDateType").setShortDisplayFormatter(new SimpleTypeFormatter() { public String format(Object value, DataClass field, DataBoundComponent component, Record record) { if (value == null) return null; return "<i>" + (((java.util.Date) value).getYear() + 1900) + "</i>"; } });Note that formatters must be added to the SimpleType definition before any DataBoundComponent binds to a DataSource that uses the SimpleType.
An example is here.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static class
static class
-
Field Summary
Fields inherited from class com.smartgwt.client.core.BaseClass
config, configOnly, factoryCreated, factoryProperties, id, scClassName
-
Constructor Summary
ConstructorDescriptionCreate a new simple type.SimpleType
(JavaScriptObject jsObj) SimpleType
(String name, SimpleType inheritsFrom) Create a new simple type.SimpleType
(String name, FieldType inheritsFrom) Create a new simple type. -
Method Summary
Modifier and TypeMethodDescriptionstatic Object
applySummaryFunction
(Record[] records, ListGridField field, SummaryFunctionType summaryFunction) Apply a standardSummaryFunctionType
to a set of records and a field.static Object
applySummaryFunction
(Record[] records, ListGridField field, String functionName) Apply a registered summary function to a set of records and a field.create()
Default value forDataSourceField.canEdit
for fields of this type.Default value forDataSourceField.canFilter
for fields of this type.In components that support grouping, the default mode from the availablegroupingModes
to use when grouping values of this type.The defaultsearch-operator
for this data-type.FormatString
used during exports for numeric or date formatting.These are properties that are essentially copied onto any DataSourceField where the property is applied.FormatString
for numeric or date formatting.A set of key-value pairs that represent the names and titles of the grouping modes available to values of this type, for use in components that support grouping.Returns a string value appropriate for the title of the group containing the passed value.Returns a group value appropriate for the passed record, field and value, in the passed component.Name of another SimpleType from which this type should inherit.getJsObj()
getName()
Name of the type, used to refer to the type fromfield.type
.static SimpleType
getOrCreateRef
(JavaScriptObject jsObj) DefaultreadOnlyDisplay
for fields of this type.static Boolean
Tells the atomic values subsystem whether to convert the incoming opaque value to a Java object when calling user getAtomicValue() and updateAtomicValue() methods.static SimpleType
Retrieve a simpleType definition by type nameboolean
void
register()
Explicitly register this SimpleType with the system so that it can be used / referenced by remote DataSources.static void
registerSummaryFunction
(String functionName, SummaryFunction summaryFunction) Registers a new SummaryFunction by name.setCanEdit
(Boolean canEdit) Default value forDataSourceField.canEdit
for fields of this type.setCanFilter
(Boolean canFilter) Default value forDataSourceField.canFilter
for fields of this type.setDefaultGroupingMode
(String defaultGroupingMode) In components that support grouping, the default mode from the availablegroupingModes
to use when grouping values of this type.setDefaultOperator
(OperatorId defaultOperator) The defaultsearch-operator
for this data-type.static void
setDefaultSummaryFunction
(String typeName, SummaryFunctionType summaryFunction) Set a default summary function for some field type.static void
setDefaultSummaryFunction
(String typeName, String functionName) Set a default summary function for some field type.void
setEditFormatter
(SimpleTypeFormatter formatter) Formatter for values of this type when displayed in a freeform text editor such as aTextItem
void
setEditorProperties
(FormItem editorProperties) DefaultFormItem
configuration for editing values of this type.void
setEditorType
(FormItem editorType) Deprecated.void
setEditorType
(Class<? extends FormItem> editorType) Set the defaultFormItem
class to be used whenever a value of this type is edited (whether in a grid, form, or other component).void
setEditorType
(String editorType) Set the defaultFormItem
class to be used whenever a value of this type is edited (whether in a grid, form, or other component).void
setEditParser
(SimpleTypeParser parser) Specify a parser to convert some user-edited value to an underlying data value of this type.setExportFormat
(String exportFormat) FormatString
used during exports for numeric or date formatting.setFieldProperties
(DataSourceField fieldProperties) These are properties that are essentially copied onto any DataSourceField where the property is applied.void
setFilterEditorProperties
(FormItem filterEditorProperties) DefaultFormItem
configuration for editing values of this type in aListGrid
filter row orSearchForm
.void
setFilterEditorType
(Class<? extends FormItem> filterEditorType) Set the defaultFormItem
class to be used whenever a value of this type appears in aListGrid
filter row orSearchForm
.void
setFilterEditorType
(String filterEditorType) Set the defaultFormItem
class to be used whenever a value of this type appears in aListGrid
filter row orSearchForm
.FormatString
for numeric or date formatting.setGroupingModes
(Map groupingModes) A set of key-value pairs that represent the names and titles of the grouping modes available to values of this type, for use in components that support grouping.void
setGroupTitleFunction
(GroupTitleFunction titleFunction) Sets customizer whosegetTitle()
method overrides the default behavior ofgetGroupTitle()
.void
setGroupValueFunction
(GroupValueFunction valueFunction) Sets customizer whosegetValue()
method overrides the default behavior ofgetGroupValue()
.void
setInheritsFrom
(FieldType inheritsFrom) Name of another SimpleType from which this type should inherit.setInheritsFrom
(String inheritsFrom) Name of another SimpleType from which this type should inherit.void
Name of the type, used to refer to the type fromfield.type
.void
setNormalDisplayFormatter
(SimpleTypeFormatter formatter) Normal formatter for values of this type used in aStaticTextItem
orDetailViewer
.setReadOnlyDisplay
(ReadOnlyDisplayAppearance readOnlyDisplay) DefaultreadOnlyDisplay
for fields of this type.void
setReadOnlyEditorProperties
(FormItem editorProperties) FormItem properties to be applied when editing values of this type in a read-only context.void
setReadOnlyEditorType
(FormItem editorType) Deprecated.Renamed tosetReadOnlyEditorProperties(FormItem)
.void
setReadOnlyEditorType
(Class<? extends FormItem> editorType) Set the defaultFormItem
class to be used whenever a value of this type is edited in a read-only context (whether in a grid, form, or other component).void
setReadOnlyEditorType
(String editorType) Set the defaultFormItem
class to be used whenever a value of this type is edited in a read-only context (whether in a grid, form, or other component).void
setShortDisplayFormatter
(SimpleTypeFormatter formatter) void
Specify a custom comparator to use for this type.void
Specify an extractor to extract an atomic value (such as a string or number) from some arbitrary live data value.void
Specify an updater to update a live data value with an edited atomic value (such as a string or number).static void
setSkipConvertOpaqueValues
(Boolean convert) Tells the atomic values subsystem whether to skip conversion of the incoming opaque value to a Java object when calling user getAtomicValue() and updateAtomicValue() methods.setValidators
(Validator... validators) Validators to apply to value of this type.setValidOperators
(OperatorId... validOperators) Set ofsearch-operators
valid for thisSimpleType
.void
setValueMap
(String... valueMap) List of legal values for this type, likevalueMap
.void
setValueMap
(Map valueMap) List of legal values for this type, likevalueMap
.Methods inherited from class com.smartgwt.client.core.BaseClass
addDynamicProperty, addDynamicProperty, addDynamicProperty, addDynamicProperty, applyFactoryProperties, asSGWTComponent, clearDynamicProperty, createJsObj, destroy, doAddHandler, doInit, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getClassName, getConfig, getHandlerCount, getID, getOrCreateJsObj, getRef, getRuleScope, getScClassName, getTestInstance, hasAutoAssignedID, hasDynamicProperty, internalSetID, internalSetID, isConfigOnly, isFactoryCreated, onBind, onInit, registerID, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setConfig, setConfigOnly, setFactoryCreated, setID, setProperty, setProperty, setProperty, setProperty, setRuleScope, setScClassName
-
Constructor Details
-
SimpleType
-
SimpleType
public SimpleType()Create a new simple type.- Parameters:
name
- the name of the simple typeinheritsFrom
- the type it inherits from
-
SimpleType
Create a new simple type.- Parameters:
name
- the name of the simple typeinheritsFrom
- the type it inherits from
-
SimpleType
Create a new simple type.- Parameters:
name
- the name of the simple typeinheritsFrom
- the type it inherits from
-
-
Method Details
-
getOrCreateRef
-
setJavaScriptObject
- Overrides:
setJavaScriptObject
in classBaseClass
-
create
-
setCanEdit
Default value forDataSourceField.canEdit
for fields of this type.This impacts client-side behavior only and is a way to simply disallow editing of this field type by default within
editors
.This property is set to false for the "sequence" SimpleType by default.
- Parameters:
canEdit
- New canEdit value. Default value is null- Returns:
SimpleType
instance, for chaining setter calls- Throws:
IllegalStateException
- this property cannot be changed after the underlying component has been created
-
getCanEdit
Default value forDataSourceField.canEdit
for fields of this type.This impacts client-side behavior only and is a way to simply disallow editing of this field type by default within
editors
.This property is set to false for the "sequence" SimpleType by default.
- Returns:
- Current canEdit value. Default value is null
-
setCanFilter
Default value forDataSourceField.canFilter
for fields of this type.This impacts client-side behavior only and may be used to explicitly enable editing in filter interfaces, even if
editing is disabled
.This property is set to true for the "sequence" SimpleType by default.
- Parameters:
canFilter
- New canFilter value. Default value is null- Returns:
SimpleType
instance, for chaining setter calls- Throws:
IllegalStateException
- this property cannot be changed after the underlying component has been created
-
getCanFilter
Default value forDataSourceField.canFilter
for fields of this type.This impacts client-side behavior only and may be used to explicitly enable editing in filter interfaces, even if
editing is disabled
.This property is set to true for the "sequence" SimpleType by default.
- Returns:
- Current canFilter value. Default value is null
-
setDefaultGroupingMode
In components that support grouping, the default mode from the availablegroupingModes
to use when grouping values of this type.- Parameters:
defaultGroupingMode
- New defaultGroupingMode value. Default value is null- Returns:
SimpleType
instance, for chaining setter calls
-
getDefaultGroupingMode
In components that support grouping, the default mode from the availablegroupingModes
to use when grouping values of this type.- Returns:
- Current defaultGroupingMode value. Default value is null
-
setDefaultOperator
The defaultsearch-operator
for this data-type.- Parameters:
defaultOperator
- New defaultOperator value. Default value is null- Returns:
SimpleType
instance, for chaining setter calls- Throws:
IllegalStateException
- this property cannot be changed after the underlying component has been created- See Also:
-
getDefaultOperator
The defaultsearch-operator
for this data-type.- Returns:
- Current defaultOperator value. Default value is null
- See Also:
-
setExportFormat
FormatString
used during exports for numeric or date formatting. SeeDataSourceField.exportFormat
.- Parameters:
exportFormat
- New exportFormat value. Default value is null- Returns:
SimpleType
instance, for chaining setter calls- Throws:
IllegalStateException
- this property cannot be changed after the underlying component has been created- See Also:
-
getExportFormat
FormatString
used during exports for numeric or date formatting. SeeDataSourceField.exportFormat
.- Returns:
- Current exportFormat value. Default value is null
- See Also:
-
setFieldProperties
These are properties that are essentially copied onto any DataSourceField where the property is applied. The supported properties are only client-side properties.- Parameters:
fieldProperties
- New fieldProperties value. Default value is null- Returns:
SimpleType
instance, for chaining setter calls- Throws:
IllegalStateException
- this property cannot be changed after the underlying component has been created
-
getFieldProperties
These are properties that are essentially copied onto any DataSourceField where the property is applied. The supported properties are only client-side properties.- Returns:
- Current fieldProperties value. Default value is null
-
setFormat
FormatString
for numeric or date formatting. SeeDataSourceField.format
.- Parameters:
format
- New format value. Default value is null- Returns:
SimpleType
instance, for chaining setter calls- Throws:
IllegalStateException
- this property cannot be changed after the underlying component has been created- See Also:
-
getFormat
FormatString
for numeric or date formatting. SeeDataSourceField.format
.- Returns:
- Current format value. Default value is null
- See Also:
-
setGroupingModes
A set of key-value pairs that represent the names and titles of the grouping modes available to values of this type, for use in components that support grouping.Some types provide a set of builtin groupingModes, as covered
here
.Use
setGroupValueFunction()
andsetGroupTitleFunction()
to implement custom grouping logic for each of the grouping modes you provide.- Parameters:
groupingModes
- New groupingModes value. Default value is null- Returns:
SimpleType
instance, for chaining setter calls
-
getGroupingModes
A set of key-value pairs that represent the names and titles of the grouping modes available to values of this type, for use in components that support grouping.Some types provide a set of builtin groupingModes, as covered
here
.Use
setGroupValueFunction()
andsetGroupTitleFunction()
to implement custom grouping logic for each of the grouping modes you provide.- Returns:
- Returns the set of
grouping modes
available for values of this type in components that support grouping. Default value is null
-
setInheritsFrom
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
- New inheritsFrom value. Default value is null- Returns:
SimpleType
instance, for chaining setter calls- Throws:
IllegalStateException
- this property cannot be changed after the underlying component has been created- See Also:
-
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:
- Current inheritsFrom value. Default value is null
- See Also:
-
setName
Name of the type, used to refer to the type fromfield.type
.- Parameters:
name
- New name value. Default value is null- Returns:
SimpleType
instance, for chaining setter calls- Throws:
IllegalStateException
- this property cannot be changed after the underlying component has been created- See Also:
-
getName
Name of the type, used to refer to the type fromfield.type
.- Returns:
- Current name value. Default value is null
- See Also:
-
setReadOnlyDisplay
public SimpleType setReadOnlyDisplay(ReadOnlyDisplayAppearance readOnlyDisplay) throws IllegalStateException DefaultreadOnlyDisplay
for fields of this type.For more sophisticated management of read-only behavior, see
readOnlyEditorType
.- Parameters:
readOnlyDisplay
- New readOnlyDisplay value. Default value is null- Returns:
SimpleType
instance, for chaining setter calls- Throws:
IllegalStateException
- this property cannot be changed after the underlying component has been created
-
getReadOnlyDisplay
DefaultreadOnlyDisplay
for fields of this type.For more sophisticated management of read-only behavior, see
readOnlyEditorType
.- Returns:
- Current readOnlyDisplay value. Default value is null
-
setValidators
Validators to apply to value of this type.- Parameters:
validators
- New validators value. Default value is null- Returns:
SimpleType
instance, for chaining setter calls- Throws:
IllegalStateException
- this property cannot be changed after the underlying component has been created- See Also:
-
setValidOperators
Set ofsearch-operators
valid for thisSimpleType
.If not specified, the
inherited
type's operators will be used, finally defaulting to the default operators for the basic types (eg, integer).- Parameters:
validOperators
- New validOperators value. Default value is null- Returns:
SimpleType
instance, for chaining setter calls- Throws:
IllegalStateException
- this property cannot be changed after the underlying component has been created- See Also:
-
getGroupTitle
public String getGroupTitle(Object value, Record record, Map field, String fieldName, Canvas component) Returns a string value appropriate for the title of the group containing the passed value.- Parameters:
value
- the record value to return a group title forrecord
- the record containing the passed group valuefield
- the field relating to the value to be processedfieldName
- the name of the field relating to the value to be processedcomponent
- the component, usually aListGrid
, containing the passed record- Returns:
- the group title for the passed parameters
-
getGroupValue
public Object getGroupValue(Object value, Record record, Map field, String fieldName, Canvas component) Returns a group value appropriate for the passed record, field and value, in the passed component.- Parameters:
value
- the record value to return a group value forrecord
- the record containing the passed valuefield
- the field relating to the value to be processedfieldName
- the name of the field relating to the value to be processedcomponent
- the component, usually aListGrid
, containing the passed record- Returns:
- the group value for the passed parameters
-
getType
Retrieve a simpleType definition by type name- Parameters:
typeName
- thename
of the simpleType to return- Returns:
- simple type object
-
register
public void register()Explicitly register this SimpleType with the system so that it can be used / referenced by remote DataSources. -
setValueMap
List of legal values for this type, likevalueMap
.- Parameters:
valueMap
- valueMap Default value is null- Throws:
IllegalStateException
- this property cannot be changed after the underlying component has been created
-
setValueMap
List of legal values for this type, likevalueMap
.- Parameters:
valueMap
- valueMap Default value is null- Throws:
IllegalStateException
- this property cannot be changed after the underlying component has been created
-
setEditorProperties
DefaultFormItem
configuration for editing values of this type.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).Note: The FormItem passed to
setEditorProperties()
is used as a "template" to create a FormItem.For an overview of the template rules, reflection requirements when trying to assign an edit Formitem by type, and an understanding of how the various
setEditorProperties()
calls on different classes relate to each other in determining what configuration ultimately gets applied to the edit FormItem, seeDataSourceField.setEditorProperties(FormItem)
.- Parameters:
editorProperties
- FormItem with default properties to use when editing- Throws:
IllegalStateException
- this property cannot be changed after the underlying component has been created- See Also:
-
setEditorType
Deprecated.Renamed tosetEditorProperties(FormItem)
. You can also consider usingsetEditorType(Class)
orsetEditorType(String)
instead.Synonym forsetEditorProperties(FormItem)
.- Parameters:
editorType
- FormItem with default properties to be applied when editing- Throws:
IllegalStateException
- this property cannot be changed after the underlying component has been created
-
setEditorType
Set the defaultFormItem
class to be used whenever a value of this type is edited (whether in a grid, form, or other component).If unset, a FormItem will be automatically chosen.
Note: The editorType must be registered for use with the
reflection mechanism
. By doing so, you avoid the limitations ofsetEditorProperties(FormItem)
. If the editorType cannot be resolved via reflection, this method will still work if editorType refers to a built-in SmartGWT framework class, such asSetFilterItem
.- Parameters:
editorType
- the fully-qualified class name of aFormItem
subclass, which must have been registered with thereflection mechanism
(except for built-in framework classes).- Throws:
IllegalArgumentException
- if the editorType class has not been registered for use with thereflection mechanism
, and it is not a built-in framework class, or if it does not inherit fromFormItem
.
-
setEditorType
Set the defaultFormItem
class to be used whenever a value of this type is edited (whether in a grid, form, or other component).If unset, a FormItem will be automatically chosen.
Note: The editorType must be registered for use with the
reflection mechanism
. By doing so, you avoid the limitations ofsetEditorProperties(FormItem)
. If the editorType cannot be resolved via reflection, this method will still work if editorType refers to a built-in SmartGWT framework class, such asSetFilterItem
.- Parameters:
editorType
- aFormItem
subclass, which must have been registered with thereflection mechanism
(except for built-in framework classes).- Throws:
IllegalArgumentException
- if the editorType class has not been registered for use with thereflection mechanism
, and it is not a built-in framework class, or if it does not inherit fromFormItem
.
-
setReadOnlyEditorProperties
FormItem properties to be applied when editing values of this type in a read-only context.Note: The FormItem passed to setReadOnlyEditorProperties() is used as a "template" to create a FormItem whenever a
DataBoundComponent
needs to show an interface for editing this field (and the field is marked read-only).For an overview of the template rules, reflection requirements when trying to assign an edit Formitem by type, and an understanding of how the various
setReadOnlyEditorProperties()
calls on different classes relate to each other in determining what configuration ultimately gets applied to the edit FormItem, seeDataSourceField.setEditorProperties(FormItem)
.- Parameters:
editorProperties
- FormItem with properties to be applied when editing values of this type in a read-only context.- Throws:
IllegalStateException
- this property cannot be changed after the underlying component has been created- See Also:
-
setReadOnlyEditorType
Deprecated.Renamed tosetReadOnlyEditorProperties(FormItem)
. You can also consider usingsetReadOnlyEditorType(Class)
orsetReadOnlyEditorType(String)
instead.Synonym forsetReadOnlyEditorProperties(FormItem)
.- Parameters:
editorType
- FormItem with default properties to be applied when editing
-
setReadOnlyEditorType
Set the defaultFormItem
class to be used whenever a value of this type is edited in a read-only context (whether in a grid, form, or other component).If unset, a FormItem will be automatically chosen.
By using the
reflection mechanism
, this method avoids the limitations described insetReadOnlyEditorProperties(FormItem)
. If the editorType cannot be resolved via reflection, this method will still work if editorType refers to a built-in SmartGWT framework class, such asSetFilterItem
.- Parameters:
editorType
- the fully-qualified class name of aFormItem
subclass, which must have been registered with thereflection mechanism
(except for built-in framework classes).- Throws:
IllegalArgumentException
- if the editorType class has not been registered for use with thereflection mechanism
, and it is not a built-in framework class, or if it does not inherit fromFormItem
.
-
setReadOnlyEditorType
Set the defaultFormItem
class to be used whenever a value of this type is edited in a read-only context (whether in a grid, form, or other component).If unset, a FormItem will be automatically chosen.
By using the
reflection mechanism
, this method avoids the limitations described insetReadOnlyEditorProperties(FormItem)
. If the editorType cannot be resolved via reflection, this method will still work if editorType refers to a built-in SmartGWT framework class, such asSetFilterItem
.- Parameters:
editorType
- aFormItem
subclass, which must have been registered with thereflection mechanism
(except for built-in framework classes).- Throws:
IllegalArgumentException
- if the editorType class has not been registered for use with thereflection mechanism
, and it is not a built-in framework class, or if it does not inherit fromFormItem
.
-
setFilterEditorProperties
DefaultFormItem
configuration for editing values of this type in aListGrid
filter row orSearchForm
.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).Note: The FormItem passed to setFilterEditorProperties() is used as a "template" to create a FormItem whenever filter rows or search forms need to show an interface for editing a field of this type.
For an overview of the template rules, reflection requirements when trying to assign an edit Formitem by type, and an understanding of how the various
setFilterEditorProperties()
calls on different classes relate to each other in determining what configuration ultimately gets applied to the edit FormItem, seeDataSourceField.setEditorProperties(FormItem)
.- Parameters:
filterEditorProperties
- FormItem with default properties to use when editing- Throws:
IllegalStateException
- this property cannot be changed after the underlying component has been created- See Also:
-
setFilterEditorType
Set the defaultFormItem
class to be used whenever a value of this type appears in aListGrid
filter row orSearchForm
.If unset, a FormItem will be automatically chosen.
Note: The filterEditorType must be registered for use with the
reflection mechanism
. By doing so, you avoid the limitations ofsetFilterEditorProperties(FormItem)
. If the filterEditorType cannot be resolved via reflection, this method will still work if filterEditorType refers to a built-in SmartGWT framework class, such asSetFilterItem
.- Parameters:
filterEditorType
- the fully-qualified class name of aFormItem
subclass, which must have been registered with thereflection mechanism
(except for built-in framework classes).- Throws:
IllegalArgumentException
- if the filterEditorType class has not been registered for use with thereflection mechanism
, and it is not a built-in framework class, or if it does not inherit fromFormItem
.
-
setFilterEditorType
Set the defaultFormItem
class to be used whenever a value of this type appears in aListGrid
filter row orSearchForm
.If unset, a FormItem will be automatically chosen.
Note: The filterEditorType must be registered for use with the
reflection mechanism
. By doing so, you avoid the limitations ofsetFilterEditorProperties(FormItem)
. If the filterEditorType cannot be resolved via reflection, this method will still work if filterEditorType refers to a built-in SmartGWT framework class, such asSetFilterItem
.- Parameters:
filterEditorType
- aFormItem
subclass, which must have been registered with thereflection mechanism
(except for built-in framework classes).- Throws:
IllegalArgumentException
- if the filterEditorType class has not been registered for use with thereflection mechanism
, and it is not a built-in framework class, or if it does not inherit fromFormItem
.
-
setInheritsFrom
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
-
setNormalDisplayFormatter
Normal formatter for values of this type used in aStaticTextItem
orDetailViewer
.A formatter can make itself configurable on a per-component or per-field basis by checking properties on the component or field. For example, a formatter for account IDs may want to omit a prefix in views where it is redundant, and could check a flag detailViewer.omitAccountIdPrefix for this purpose.
- Parameters:
formatter
- the formatter
-
setShortDisplayFormatter
Formatter for values of this type when compact display is required, for example, in aListGrid
orTreeGrid
.A formatter can make itself configurable on a per-component or per-field basis by checking properties on the component or field. For example, a formatter for account IDs may want to omit a prefix in views where it is redundant, and could check a flag listGridField.omitAccountIdPrefix for this purpose.
- Parameters:
formatter
- the formatter
-
setEditFormatter
Formatter for values of this type when displayed in a freeform text editor such as aTextItem
See also
#parseInput
for parsing an edited text value back to a data value.- Parameters:
formatter
- the formatter
-
setEditParser
Specify a parser to convert some user-edited value to an underlying data value of this type. This parser is called when storing out values edited in a freeform editor such as aTextItem
. Typically this will convert from the format produced by#editFormatter
back to a data value.- Parameters:
parser
- the parser
-
setSkipConvertOpaqueValues
Tells the atomic values subsystem whether to skip conversion of the incoming opaque value to a Java object when calling user getAtomicValue() and updateAtomicValue() methods. By default, we do convert the opaque value, and your methods will be passed a Java object - typically a Map of native Java types. Passing true to this method switches off conversion, and your methods will be passed a JavaScriptObject- Parameters:
convert
- Whether the atomic values subsystem should skip conversion of opaque values to native Java types
-
getSkipConvertOpaqueValues
Tells the atomic values subsystem whether to convert the incoming opaque value to a Java object when calling user getAtomicValue() and updateAtomicValue() methods. By default, we do convert the opaque value, and your methods will be passed a Java object - typically a Map of native Java types. Passing false to this mehtod switches off conversion, and your methods will be passed a JavaScriptObject- Returns:
- Boolean indicating whether the atomic values subsystem will convert opaque values to native Java types
-
setSimpleTypeValueExtractor
Specify an extractor to extract an atomic value (such as a string or number) from some arbitrary live data value. If defined this method will be called for every field value of the specified type in order to convert from the raw data value to an atomic type to be used for standard DataBinding features such as sorting and editing.- Parameters:
extractor
- the extractor
-
setSimpleTypeValueUpdater
Specify an updater to update a live data value with an edited atomic value (such as a string or number). If defined this updater's updateAtomicValue method will be called when the user edits data in a field of this type, allowing the developer to convert from the atomic type to a raw data value for storage.- Parameters:
extractor
- the updater
-
setSimpleTypeValueComparator
Specify a custom comparator to use for this type.If defined, this comparator's compareValues() method will be called when the framework needs to compares values of this type for equality.
- Parameters:
comparator
- the comparator
-
isCreated
public boolean isCreated() -
getJsObj
-
registerSummaryFunction
Registers a new SummaryFunction by name. After calling this method, developers may specify the name passed in as a standard summaryFunction (for example in ListGridField.setSummaryFunction()). Note that if the specified name conflicts with one of the built in SummaryFunctionType values, a RuntimeException will be thrown.- Parameters:
functionName
- name for the SummaryFunctionsummaryFunction
- new SummaryFunction implementation
-
applySummaryFunction
public static Object applySummaryFunction(Record[] records, ListGridField field, SummaryFunctionType summaryFunction) Apply a standardSummaryFunctionType
to a set of records and a field.- Parameters:
records
- records to obtain the summary value forfield
- field on which the summary function is being runsummaryFunction
- standard summary function identifier- Returns:
- result of the summary function.
-
applySummaryFunction
public static Object applySummaryFunction(Record[] records, ListGridField field, String functionName) Apply a registered summary function to a set of records and a field.- Parameters:
records
- records to obtain the summary value forfield
- field on which the summary function is being runfunctionName
- name under which the summary function is registered. SeeregisterSummaryFunction(String, SummaryFunction)
- Returns:
- result of the summary function.
-
setDefaultSummaryFunction
Set a default summary function for some field type.- Parameters:
typeName
- name of the field type. If this is the name of a custom SimpleType, the developer may need to ensure the type isregistered
.summaryFunction
- standard summary function type for this data type
-
setDefaultSummaryFunction
Set a default summary function for some field type.- Parameters:
typeName
- name of the field type. If this is the name of a custom SimpleType, the developer may need to ensure the type isregistered
.summaryFunction
- name under which the summary function is registered. SeeregisterSummaryFunction(String, SummaryFunction)
-
setGroupTitleFunction
Sets customizer whosegetTitle()
method overrides the default behavior ofgetGroupTitle()
. Pass null to clear the override. -
setGroupValueFunction
Sets customizer whosegetValue()
method overrides the default behavior ofgetGroupValue()
. Pass null to clear the override.
-
setEditorProperties(FormItem)
.