public class DataSourceField extends DataClass
factoryCreated, factoryProperties
Constructor and Description |
---|
DataSourceField() |
DataSourceField(com.google.gwt.core.client.JavaScriptObject jsObj) |
DataSourceField(java.lang.String name,
FieldType type) |
DataSourceField(java.lang.String name,
FieldType type,
java.lang.String title) |
DataSourceField(java.lang.String name,
FieldType type,
java.lang.String title,
int length) |
DataSourceField(java.lang.String name,
FieldType type,
java.lang.String title,
int length,
boolean required) |
Modifier and Type | Method and Description |
---|---|
java.lang.Boolean |
getCanEdit()
Controls whether, by default, dataBoundComponents consider this field editable.
|
java.lang.Boolean |
getCanExport()
Dictates whether the data in this field be exported.
|
java.lang.Boolean |
getCanFilter()
Should the user be able to filter data by this field? Affects whether this field will show up in dataBoundComponents
with UI for filtering data.
|
java.lang.Boolean |
getCanSave()
Whether values in this field can be updated and saved to the dataSource.
|
boolean |
getCanSortClientOnly()
When true, this field can only be used for sorting if the data is entirely client-side.
|
java.lang.Boolean |
getCanView()
If false, this property indicates that this field is considered "server only".
|
java.lang.Boolean |
getChildrenProperty()
If true, this property indicates that this field will hold an explicit array of child nodes for the current node.
|
java.lang.String |
getChildTagName()
For a field that is
multiple:"true" , controls the name of
the XML tag used for each subelement during DataSource.xmlSerialize() . |
DateDisplayFormat |
getDateFormatter()
Preferred display format to use for date type values within this field.
|
java.lang.Integer |
getDecimalPad()
Applies only to fields of type "float" and enforces a minimum number of digits shown after the decimal point.
|
java.lang.Integer |
getDecimalPrecision()
Applies only to fields of type "float" and affects how many significant digits are shown.
|
java.lang.Boolean |
getDeepCloneOnEdit()
Before we start editing this field in a DataBoundComponent, should we perform a deep clone of the underlying field
value.
|
OperatorId |
getDefaultOperator()
The default search-operator for this field.
|
boolean |
getDetail()
Whether this field should be considered a "detail" field by a
DataBoundComponent . |
java.lang.String |
getDisplayField()
When records from this dataSource are displayed in a dataBoundComponent such as a
ListGrid , the displayField attribute may be used to cause some field to
display a value from another field in the record. |
java.lang.String |
getEmptyDisplayValue()
Text to be used for display by client-side components when this field has a null or undefined value.
|
java.lang.Boolean |
getEscapeHTML()
When data values are displayed in DataBound components, by default strings will be interpreted as HTML by the browser in
most cases.
|
java.lang.Boolean |
getExcludeFromState()
If true, then this field is excluded from the bound component's view state.
|
boolean |
getExportForceText()
When using
DataSource.recordsAsText() , determines what
approach (if any) should be used to force values to be intepreted as text instead of heuristically parsed as dates,
times or other structured types. |
java.lang.String |
getExportFormat()
An optional
FormatString for this field, for use when exporting data to spreadsheet formats (XLS and OOXML/XLSX),
XML, JSON or CSV. |
java.lang.String |
getExportTitle()
Optional different field-title used for exports.
|
java.lang.String |
getForeignDisplayField()
Name of another field in a separate dataSource that should be used as the display
value for this field in the case where a
foreignKey relationship
exists. |
java.lang.String |
getForeignKey()
Declares that this field holds values that can be matched to values from another DataSource
field, to create a relationship between records from different DataSources or even records
within the same DataSource.
|
java.lang.String |
getFormat()
Format string to use when rendering the value in any
DataBoundComponent or when
exporting via DataSource.exportData() or ListGrid.exportData() or ListGrid.exportClientData() . |
java.lang.String |
getGroup()
For use in
ComponentSchema , indicates what group to place the property in when editing
in Visual Builder. |
boolean |
getHidden()
Whether this field should be hidden from users by default within a DataBound component.
|
java.lang.Boolean |
getIgnoreTextMatchStyle()
NOTE: Only applicable to
clientOnly DataSources and the
built-in SQL , JPA and
Hibernate DataSources available in Pro, Power and Enterprise
versions of Smart GWT. |
java.lang.Integer |
getImageHeight()
Height of the image-content of this field.
|
java.lang.String |
getImageHeightAsString()
Height of the image-content of this field.
|
java.lang.Integer |
getImageSize()
Width and height of the image-content of this field.
|
java.lang.String |
getImageSizeAsString()
Width and height of the image-content of this field.
|
java.lang.Integer |
getImageWidth()
Width of the image-content of this field.
|
java.lang.String |
getImageWidthAsString()
Width of the image-content of this field.
|
java.lang.Boolean |
getInapplicable()
For use in
ComponentSchema , a field inherited from another schema can be redeclared with this property
set in order to indicate that the property should not be used. |
java.lang.String |
getJoinPrefix()
Defines prefix before concatenated values if field is used with
Server
summaries feature and the summary function is "concat". |
java.lang.String |
getJoinString()
Defines the delimiter between concatenated values if field is used with
Server summaries feature and the summary function is "concat". |
java.lang.String |
getJoinSuffix()
Defines suffix after concatenated values if field is used with
Server
summaries feature and the summary function is "concat". |
java.lang.Integer |
getLength()
Maximum number of characters allowed.
|
java.lang.Boolean |
getLenientXPath()
Deprecated.
No longer needs to be set since the framework now defaults to suppressing errors for null values in the middle of
Xpath, and only invalid XPath will cause warning be logged.
|
java.lang.Boolean |
getMultiple()
Indicates that this field should always be Array-valued.
|
java.lang.String |
getMultipleValueSeparator()
For fields that are
multiple:true , the separator used
between values when they are displayed. |
java.lang.String |
getName()
Name for this field.
|
java.lang.Boolean |
getNillable()
Controls whether an explicit null-valued Record attribute for this field
should result in
xsi:nil being used to transmit the value when serializing
to XML, like so: |
static DataSourceField |
getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj) |
java.lang.String |
getPluralTitle()
Return the plural title.
|
java.lang.Integer |
getPrecision()
Applies only to fields of type "float" or "integer" and affects how many significant digits are shown.
|
boolean |
getPrimaryKey()
Indicates either that this field holds a value unique across all records in this DataSource, or that it is
one of a number of fields marked as primary keys, and the combination of the values held in all of those fields is
unique across all records in the DataSource.
|
java.lang.String |
getPrompt()
Causes a tooltip hover to appear on the header generated for this field (effectively sets
prompt for the header). |
java.lang.Boolean |
getPropertiesOnly()
For use in
ComponentSchema for fields that contain other components, this flag
suppresses auto-construction for subcomponents that appear under this field. |
boolean |
getRequired()
Indicates this field must be non-null in order for a record to pass validation.
|
java.lang.String |
getRequiredMessage()
The required message when a field that has been marked as
required is not filled in by the user. |
java.lang.Object |
getRootValue()
For a field that is a foreignKey establishing a tree relationship, what value indicates a root-level node.
|
java.lang.String |
getSequenceName()
For a DataSource with
serverType:"sql" with a field of
type
"sequence", the name of the SQL sequence that should be used when inserting new records into
this table. |
java.lang.Boolean |
getShowFileInline()
For a field of type:"imageFile", indicates whether to stream the image and display it inline or to display the View and
Download icons.
|
java.lang.String |
getSortByField()
Causes values for this field to be sorted according to values for another field, for both client- and server-side
sorting.
|
java.lang.Boolean |
getStringInBrowser()
Server-side setting that causes values for fields of type "integer" or "float" to be represented as Strings when
delivered to a web browser, in order to avoid mangling values which cannot be represented faithfully in JavaScript.
|
SummaryFunctionType |
getSummaryFunction()
If
showGridSummary or showGroupSummary is true, this attribute can be used to
specify an explicit SummaryFunction for calculating the summary value to display. |
java.lang.String |
getSummaryValueTitle()
Title to show in a
Summary of type "title" for this field. |
TimeDisplayFormat |
getTimeFormatter()
Preferred time-format to apply to date type values within this field.
|
java.lang.String |
getTitle()
Default user-visible title for this field.
|
FieldType |
getType()
Type of this field.
|
DataSource |
getTypeAsDataSource()
Return the type of the assigned DataSource
|
SimpleType |
getTypeAsSimpleType()
Returns the type of this field as a SimpleType.
|
java.lang.String |
getUploadFieldName()
Used by the
BatchUploader to map a field in an upload file to this dataSourceField. |
java.lang.Boolean |
getUseLocalDisplayFieldValue()
The
FormItem.useLocalDisplayFieldValue attribute may be specified within a dataSource configuration. |
Validator[] |
getValidators()
Validators to be applied to this field.
|
OperatorId[] |
getValidOperators()
Set of search-operators valid for this field.
|
java.util.Map |
getValueMap()
A
com.smartgwt.client.types.ValueMap is a set of legal values for a field. |
java.lang.String |
getValueXPath()
XPath expression used to retrieve the field's value.
|
java.lang.Boolean |
getXmlAttribute()
Indicates that
DataSource.xmlSerialize() should serialize this
value as an XML attribute. |
void |
setCanEdit(java.lang.Boolean canEdit)
Controls whether, by default, dataBoundComponents consider this field editable.
|
DataSourceField |
setCanExport(java.lang.Boolean canExport)
Dictates whether the data in this field be exported.
|
DataSourceField |
setCanFilter(java.lang.Boolean canFilter)
Should the user be able to filter data by this field? Affects whether this field will show up in dataBoundComponents
with UI for filtering data.
|
DataSourceField |
setCanSave(java.lang.Boolean canSave)
Whether values in this field can be updated and saved to the dataSource.
|
DataSourceField |
setCanSortClientOnly(boolean canSortClientOnly)
When true, this field can only be used for sorting if the data is entirely client-side.
|
DataSourceField |
setCanView(java.lang.Boolean canView)
If false, this property indicates that this field is considered "server only".
|
DataSourceField |
setChildrenProperty(java.lang.Boolean childrenProperty)
If true, this property indicates that this field will hold an explicit array of child nodes for the current node.
|
DataSourceField |
setChildTagName(java.lang.String childTagName)
For a field that is
multiple:"true" , controls the name of
the XML tag used for each subelement during DataSource.xmlSerialize() . |
DataSourceField |
setDateFormatter(DateDisplayFormat dateFormatter)
Preferred display format to use for date type values within this field.
|
DataSourceField |
setDecimalPad(java.lang.Integer decimalPad)
Applies only to fields of type "float" and enforces a minimum number of digits shown after the decimal point.
|
DataSourceField |
setDecimalPrecision(java.lang.Integer decimalPrecision)
Applies only to fields of type "float" and affects how many significant digits are shown.
|
DataSourceField |
setDeepCloneOnEdit(java.lang.Boolean deepCloneOnEdit)
Before we start editing this field in a DataBoundComponent, should we perform a deep clone of the underlying field
value.
|
DataSourceField |
setDefaultOperator(OperatorId defaultOperator)
The default search-operator for this field.
|
DataSourceField |
setDetail(boolean detail)
Whether this field should be considered a "detail" field by a
DataBoundComponent . |
DataSourceField |
setDisplayField(java.lang.String displayField)
When records from this dataSource are displayed in a dataBoundComponent such as a
ListGrid , the displayField attribute may be used to cause some field to
display a value from another field in the record. |
void |
setEditorProperties(FormItem editorProperties)
Set the default
FormItem properties to be used whenever this
field is edited (whether in a grid, form, or other component). |
void |
setEditorType(java.lang.Class<? extends FormItem> editorType)
Set the default
FormItem class to be used whenever this field is edited
(whether in a grid, form, or other component). |
void |
setEditorType(FormItem editorType)
Deprecated.
Renamed to
setEditorProperties(FormItem) . You can also consider using
setEditorType(Class) or setEditorType(String) instead. |
void |
setEditorType(java.lang.String editorType)
Set the default
FormItem class to be used whenever this field is edited
(whether in a grid, form, or other component). |
DataSourceField |
setEmptyDisplayValue(java.lang.String emptyDisplayValue)
Text to be used for display by client-side components when this field has a null or undefined value.
|
DataSourceField |
setEscapeHTML(java.lang.Boolean escapeHTML)
When data values are displayed in DataBound components, by default strings will be interpreted as HTML by the browser in
most cases.
|
DataSourceField |
setExcludeFromState(java.lang.Boolean excludeFromState)
If true, then this field is excluded from the bound component's view state.
|
DataSourceField |
setExportForceText(boolean exportForceText)
When using
DataSource.recordsAsText() , determines what
approach (if any) should be used to force values to be intepreted as text instead of heuristically parsed as dates,
times or other structured types. |
DataSourceField |
setExportFormat(java.lang.String exportFormat)
An optional
FormatString for this field, for use when exporting data to spreadsheet formats (XLS and OOXML/XLSX),
XML, JSON or CSV. |
DataSourceField |
setExportTitle(java.lang.String exportTitle)
Optional different field-title used for exports.
|
void |
setFieldValueExtractor(FieldValueExtractor extractor)
Function to retrieve the field's value from the XML element or JSON record returned
from a web service.
|
void |
setFilterEditorProperties(FormItem filterEditorProperties)
|
void |
setFilterEditorType(java.lang.Class<? extends FormItem> filterEditorType)
Set the default
FormItem class to be used whenever this field appears
in a ListGrid filter row or
SearchForm . |
void |
setFilterEditorType(java.lang.String filterEditorType)
Set the default
FormItem class to be used whenever this field appears
in a ListGrid filter row or
SearchForm . |
DataSourceField |
setForeignDisplayField(java.lang.String foreignDisplayField)
Name of another field in a separate dataSource that should be used as the display
value for this field in the case where a
foreignKey relationship
exists. |
DataSourceField |
setForeignKey(java.lang.String foreignKey)
Declares that this field holds values that can be matched to values from another DataSource
field, to create a relationship between records from different DataSources or even records
within the same DataSource.
|
DataSourceField |
setFormat(java.lang.String format)
Format string to use when rendering the value in any
DataBoundComponent or when
exporting via DataSource.exportData() or ListGrid.exportData() or ListGrid.exportClientData() . |
DataSourceField |
setGroup(java.lang.String group)
For use in
ComponentSchema , indicates what group to place the property in when editing
in Visual Builder. |
DataSourceField |
setHidden(boolean hidden)
Whether this field should be hidden from users by default within a DataBound component.
|
DataSourceField |
setIgnoreTextMatchStyle(java.lang.Boolean ignoreTextMatchStyle)
NOTE: Only applicable to
clientOnly DataSources and the
built-in SQL , JPA and
Hibernate DataSources available in Pro, Power and Enterprise
versions of Smart GWT. |
void |
setImageHeight(java.lang.Integer imageHeight)
Height of the image-content of this field.
|
void |
setImageHeight(java.lang.String imageHeight)
Height of the image-content of this field.
|
void |
setImageSize(java.lang.Integer imageSize)
Width and height of the image-content of this field.
|
void |
setImageSize(java.lang.String imageSize)
Width and height of the image-content of this field.
|
void |
setImageWidth(java.lang.Integer imageWidth)
Width of the image-content of this field.
|
void |
setImageWidth(java.lang.String imageWidth)
Width of the image-content of this field.
|
DataSourceField |
setInapplicable(java.lang.Boolean inapplicable)
For use in
ComponentSchema , a field inherited from another schema can be redeclared with this property
set in order to indicate that the property should not be used. |
DataSourceField |
setJoinPrefix(java.lang.String joinPrefix)
Defines prefix before concatenated values if field is used with
Server
summaries feature and the summary function is "concat". |
DataSourceField |
setJoinString(java.lang.String joinString)
Defines the delimiter between concatenated values if field is used with
Server summaries feature and the summary function is "concat". |
DataSourceField |
setJoinSuffix(java.lang.String joinSuffix)
Defines suffix after concatenated values if field is used with
Server
summaries feature and the summary function is "concat". |
DataSourceField |
setLength(java.lang.Integer length)
Maximum number of characters allowed.
|
DataSourceField |
setLenientXPath(java.lang.Boolean lenientXPath)
Deprecated.
No longer needs to be set since the framework now defaults to suppressing errors for null values in the middle of
Xpath, and only invalid XPath will cause warning be logged.
|
DataSourceField |
setMultiple(java.lang.Boolean multiple)
Indicates that this field should always be Array-valued.
|
DataSourceField |
setMultipleValueSeparator(java.lang.String multipleValueSeparator)
For fields that are
multiple:true , the separator used
between values when they are displayed. |
DataSourceField |
setName(java.lang.String name)
Name for this field.
|
DataSourceField |
setNillable(java.lang.Boolean nillable)
Controls whether an explicit null-valued Record attribute for this field
should result in
xsi:nil being used to transmit the value when serializing
to XML, like so: |
void |
setPluralTitle(java.lang.String pluralTitle)
Set the plural title.
|
DataSourceField |
setPrecision(java.lang.Integer precision)
Applies only to fields of type "float" or "integer" and affects how many significant digits are shown.
|
DataSourceField |
setPrimaryKey(boolean primaryKey)
Indicates either that this field holds a value unique across all records in this DataSource, or that it is
one of a number of fields marked as primary keys, and the combination of the values held in all of those fields is
unique across all records in the DataSource.
|
void |
setPrompt(java.lang.String prompt)
Causes a tooltip hover to appear on the header generated for this data source field (effectively sets
prompt for the header). |
DataSourceField |
setPropertiesOnly(java.lang.Boolean propertiesOnly)
For use in
ComponentSchema for fields that contain other components, this flag
suppresses auto-construction for subcomponents that appear under this field. |
void |
setReadOnlyEditorProperties(FormItem editorProperties)
Sets the default FormItem properties to be used if this field is marked as
canEdit false and displayed in an editor component such as a DynamicForm. |
void |
setReadOnlyEditorType(java.lang.Class<? extends FormItem> editorType)
Sets the default
FormItem class to be used if this field is marked as
canEdit false and displayed in an editor component such as a DynamicForm. |
void |
setReadOnlyEditorType(FormItem editorType)
Deprecated.
Renamed to
setReadOnlyEditorProperties(FormItem) . You can
also consider using setReadOnlyEditorType(Class) or
setReadOnlyEditorType(String) instead. |
void |
setReadOnlyEditorType(java.lang.String editorType)
Sets the default FormItem class to be used if this field is marked as
canEdit false and displayed in an editor component
such as a DynamicForm. |
DataSourceField |
setRequired(boolean required)
Indicates this field must be non-null in order for a record to pass validation.
|
DataSourceField |
setRequiredMessage(java.lang.String requiredMessage)
The required message when a field that has been marked as
required is not filled in by the user. |
void |
setRootValue(java.lang.Float rootValue)
For a field that is a foreignKey establishing a tree relationship, what value indicates a root-level node.
|
void |
setRootValue(java.lang.Integer rootValue)
For a field that is a foreignKey establishing a tree relationship, what value indicates a root-level node.
|
DataSourceField |
setRootValue(java.lang.Object rootValue)
For a field that is a foreignKey establishing a tree relationship, what value indicates a root-level node.
|
void |
setRootValue(java.lang.String rootValue)
For a field that is a foreignKey establishing a tree relationship, what value indicates a root-level node.
|
DataSourceField |
setSequenceName(java.lang.String sequenceName)
For a DataSource with
serverType:"sql" with a field of
type
"sequence", the name of the SQL sequence that should be used when inserting new records into
this table. |
DataSourceField |
setShowFileInline(java.lang.Boolean showFileInline)
For a field of type:"imageFile", indicates whether to stream the image and display it inline or to display the View and
Download icons.
|
DataSourceField |
setSortByField(java.lang.String sortByField)
Causes values for this field to be sorted according to values for another field, for both client- and server-side
sorting.
|
DataSourceField |
setStringInBrowser(java.lang.Boolean stringInBrowser)
Server-side setting that causes values for fields of type "integer" or "float" to be represented as Strings when
delivered to a web browser, in order to avoid mangling values which cannot be represented faithfully in JavaScript.
|
void |
setSummaryFunction(java.lang.String summaryFunction)
If
showGridSummary or showGroupSummary is true, this attribute can be used to
specify an summary function registered via com.smartgwt.client.data.SimpleType#registerSummaryFunction()
for calculating the summary value to display. |
void |
setSummaryFunction(SummaryFunction summaryFunction)
If
showGridSummary or showGroupSummary is true, this attribute can be used to
specify an explicit SummaryFunction for calculating the summary value to display. |
void |
setSummaryFunction(SummaryFunctionType summaryFunction)
If
showGridSummary or showGroupSummary is true, this attribute can be used to
specify an explicit SummaryFunction for calculating the summary value to display. |
DataSourceField |
setSummaryValueTitle(java.lang.String summaryValueTitle)
Title to show in a
Summary of type "title" for this field. |
DataSourceField |
setTimeFormatter(TimeDisplayFormat timeFormatter)
Preferred time-format to apply to date type values within this field.
|
DataSourceField |
setTitle(java.lang.String title)
Default user-visible title for this field.
|
void |
setType(DataSource dataSource)
Deprecated.
use #setTypeAsDataSource
|
DataSourceField |
setType(FieldType type)
Type of this field.
|
void |
setType(SimpleType type)
Set the type directly to a defined SimpleType.
|
void |
setTypeAsDataSource(DataSource dataSource)
The type can also be the another DataSource, which allows you to model nested structures such as XML documents (in fact, XMLTools.loadXMLSchema()
models XML schema in this way).
|
DataSourceField |
setUploadFieldName(java.lang.String uploadFieldName)
Used by the
BatchUploader to map a field in an upload file to this dataSourceField. |
DataSourceField |
setUseLocalDisplayFieldValue(java.lang.Boolean useLocalDisplayFieldValue)
The
FormItem.useLocalDisplayFieldValue attribute may be specified within a dataSource configuration. |
DataSourceField |
setValidators(Validator... validators)
Validators to be applied to this field.
|
DataSourceField |
setValidOperators(OperatorId... validOperators)
Set of search-operators valid for this field.
|
DataSourceField |
setValueMap(java.util.Map valueMap)
A
com.smartgwt.client.types.ValueMap is a set of legal values for a field. |
void |
setValueMap(java.lang.String... valueMap)
A ValueMap is a set of legal values for a field.
|
DataSourceField |
setValueXPath(java.lang.String valueXPath)
XPath expression used to retrieve the field's value.
|
DataSourceField |
setXmlAttribute(java.lang.Boolean xmlAttribute)
Indicates that
DataSource.xmlSerialize() should serialize this
value as an XML attribute. |
applyFactoryProperties, doAddHandler, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsDoubleArray, getAttributeAsFloat, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsJavaScriptObject, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsString, getAttributeAsStringArray, getAttributes, getHandlerCount, isFactoryCreated, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeAsJavaObject, setFactoryCreated
public DataSourceField()
public DataSourceField(com.google.gwt.core.client.JavaScriptObject jsObj)
public DataSourceField(java.lang.String name, FieldType type)
public DataSourceField(java.lang.String name, FieldType type, java.lang.String title)
public DataSourceField(java.lang.String name, FieldType type, java.lang.String title, int length)
public DataSourceField(java.lang.String name, FieldType type, java.lang.String title, int length, boolean required)
public static DataSourceField getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
public DataSourceField setCanExport(java.lang.Boolean canExport)
ListGrid
fields
.canExport
- New canExport value. Default value is nullDataSourceField
instance, for chaining setter callspublic java.lang.Boolean getCanExport()
ListGrid
fields
.public DataSourceField setCanFilter(java.lang.Boolean canFilter)
Note that setting canFilter:false
only affects UI and is not a security
feature. Enforcing that filtering cannot be performed server side does not meaningfully increase security, since as
long as a field can be viewed by an end user, they can effectively search the field themselves even if the UI doesn't
offer a means to do so. If a field should be unable to be viewed entirely by some users, use viewRequiresRole
and related settings.
Rather
than a security setting, canFilter:false
is intended for situations where it would be redundant or
nonsensical to be able to search on a field, or where searching isn't implemented for that field.
canFilter
- New canFilter value. Default value is nullDataSourceField
instance, for chaining setter callsSearchForm.setShowFilterFieldsOnly(java.lang.Boolean)
,
SearchForm.setCanEditFieldAttribute(java.lang.String)
public java.lang.Boolean getCanFilter()
Note that setting canFilter:false
only affects UI and is not a security
feature. Enforcing that filtering cannot be performed server side does not meaningfully increase security, since as
long as a field can be viewed by an end user, they can effectively search the field themselves even if the UI doesn't
offer a means to do so. If a field should be unable to be viewed entirely by some users, use viewRequiresRole
and related settings.
Rather
than a security setting, canFilter:false
is intended for situations where it would be redundant or
nonsensical to be able to search on a field, or where searching isn't implemented for that field.
SearchForm.getShowFilterFieldsOnly()
,
SearchForm.getCanEditFieldAttribute()
public DataSourceField setCanSave(java.lang.Boolean canSave)
If set to false
, this field
will default to being non-editable in standard editing components (DynamicForm
,
editable ListGrid
), but will be editable when displayed for filtering purposes
only (in a SearchForm
or ListGrid\n filter editor
. If canEdit
is explicitly specified it will take precedence over this
client-side behavior, but the server will still enforce the no-save policy (described below).
NOTE: If you are using
Smart GWT Server and have specified canSave: false
for a field in a DataSource definition
(.ds.xml
file), this is enforced on the server. This means that we will strip out any attempt to set the
value of such a field before trying to process any update or add request, similar to what happens when a field-level declarative security check
fails.
canSave
- New canSave value. Default value is nullDataSourceField
instance, for chaining setter callsComponentBinding overview and related methods
public java.lang.Boolean getCanSave()
If set to false
, this field
will default to being non-editable in standard editing components (DynamicForm
,
editable ListGrid
), but will be editable when displayed for filtering purposes
only (in a SearchForm
or ListGrid\n filter editor
. If canEdit
is explicitly specified it will take precedence over this
client-side behavior, but the server will still enforce the no-save policy (described below).
NOTE: If you are using
Smart GWT Server and have specified canSave: false
for a field in a DataSource definition
(.ds.xml
file), this is enforced on the server. This means that we will strip out any attempt to set the
value of such a field before trying to process any update or add request, similar to what happens when a field-level declarative security check
fails.
ComponentBinding overview and related methods
public DataSourceField setCanSortClientOnly(boolean canSortClientOnly)
canSortClientOnly
- New canSortClientOnly value. Default value is falseDataSourceField
instance, for chaining setter callspublic boolean getCanSortClientOnly()
public DataSourceField setCanView(java.lang.Boolean canView)
dataBoundComponent
, it will be droppedcanEdit
, no updates to the field are allowed
from the client. If you explicitly add a value for the field to, eg, a record you are passing to DataSource.updateData()
, the server will strip the value out of the
record before processing the update request. canView:false
is not the same thing as hidden
. Use canView:false
when you want to prevent
the client from ever seeing a field's definition or values; use hidden:true
if it is fine from a security
perspective that a field's definition and values are sent to the browser, but the field should not by default appear in
user interface elements (but could do in some cases, like a special screen for advanced users or administrators, for
example). Note that this property must be set explicitly to false to have an effect; a null or undefined setting is treated the same as true.
This property is used to implement field-level view security: failing a viewRequiresAuthentication
, viewRequiresRole
or viewRequires
test is equivalent to setting
canView:false
on the field (and, indeed, from the client's perspective, the field has had
canView:false
set).
canView
- New canView value. Default value is nullDataSourceField
instance, for chaining setter callsComponentBinding overview and related methods
public java.lang.Boolean getCanView()
dataBoundComponent
, it will be droppedcanEdit
, no updates to the field are allowed
from the client. If you explicitly add a value for the field to, eg, a record you are passing to DataSource.updateData()
, the server will strip the value out of the
record before processing the update request. canView:false
is not the same thing as hidden
. Use canView:false
when you want to prevent
the client from ever seeing a field's definition or values; use hidden:true
if it is fine from a security
perspective that a field's definition and values are sent to the browser, but the field should not by default appear in
user interface elements (but could do in some cases, like a special screen for advanced users or administrators, for
example). Note that this property must be set explicitly to false to have an effect; a null or undefined setting is treated the same as true.
This property is used to implement field-level view security: failing a viewRequiresAuthentication
, viewRequiresRole
or viewRequires
test is equivalent to setting
canView:false
on the field (and, indeed, from the client's perspective, the field has had
canView:false
set).
ComponentBinding overview and related methods
public DataSourceField setChildrenProperty(java.lang.Boolean childrenProperty)
DataSource.childrenField
to this field's name.childrenProperty
- New childrenProperty value. Default value is falseDataSourceField
instance, for chaining setter callsDataSource.setChildrenField(java.lang.String)
,
DataSourceRelations overview and related methods
public java.lang.Boolean getChildrenProperty()
DataSource.childrenField
to this field's name.DataSource.getChildrenField()
,
DataSourceRelations overview and related methods
public DataSourceField setChildTagName(java.lang.String childTagName)
multiple:"true"
, controls the name of
the XML tag used for each subelement during DataSource.xmlSerialize()
. If unset, the default tag name is "value" for a field of simple type, and for a field of
DataSource type, is the tagName or ID of the DataSource (as though xmlSerialize()
were called on the child
DataSource).
childTagName
- New childTagName value. Default value is nullDataSourceField
instance, for chaining setter callsComponentSchema overview and related methods
public java.lang.String getChildTagName()
multiple:"true"
, controls the name of
the XML tag used for each subelement during DataSource.xmlSerialize()
. If unset, the default tag name is "value" for a field of simple type, and for a field of
DataSource type, is the tagName or ID of the DataSource (as though xmlSerialize()
were called on the child
DataSource).
ComponentSchema overview and related methods
public DataSourceField setDateFormatter(DateDisplayFormat dateFormatter)
DynamicForm
or ListGrid
it will be respected (See FormItem.dateFormatter
and ListGridField.dateFormatter
). Note that this property is also honored when exporting directly to Excel spreadsheets (ie, when using XLS or XLSX/OOXML form, not CSV); "date" and "datetime" fields with this property set will deliver real dates and formatting information to Excel, rather than formatted strings or unformatted dates.
Note : This is an advanced setting
dateFormatter
- New dateFormatter value. Default value is nullDataSourceField
instance, for chaining setter callsAppearance overview and related methods
public DateDisplayFormat getDateFormatter()
DynamicForm
or ListGrid
it will be respected (See FormItem.dateFormatter
and ListGridField.dateFormatter
). Note that this property is also honored when exporting directly to Excel spreadsheets (ie, when using XLS or XLSX/OOXML form, not CSV); "date" and "datetime" fields with this property set will deliver real dates and formatting information to Excel, rather than formatted strings or unformatted dates.
Appearance overview and related methods
public DataSourceField setDecimalPad(java.lang.Integer decimalPad)
For example, a field value of 343.1, 343.104 and 343.09872677 would all be shown as 343.10 if decimalPad is 2.
The original unpadded value is always shown when the value is edited.
decimalPad
- New decimalPad value. Default value is nullDataSourceField
instance, for chaining setter callsAppearance overview and related methods
public java.lang.Integer getDecimalPad()
For example, a field value of 343.1, 343.104 and 343.09872677 would all be shown as 343.10 if decimalPad is 2.
The original unpadded value is always shown when the value is edited.
Appearance overview and related methods
public DataSourceField setDecimalPrecision(java.lang.Integer decimalPrecision)
For example, with decimalPrecision 3, if the field value is 343.672677, 343.673 is shown.
If the value is 125.2, 125.2 is shown -
decimalPrecision will not cause extra zeros to be added. Use decimalPad
for this.
A number is always shown with its original precision when edited.
decimalPrecision
- New decimalPrecision value. Default value is nullDataSourceField
instance, for chaining setter callsAppearance overview and related methods
public java.lang.Integer getDecimalPrecision()
For example, with decimalPrecision 3, if the field value is 343.672677, 343.673 is shown.
If the value is 125.2, 125.2 is shown -
decimalPrecision will not cause extra zeros to be added. Use decimalPad
for this.
A number is always shown with its original precision when edited.
Appearance overview and related methods
public DataSourceField setDeepCloneOnEdit(java.lang.Boolean deepCloneOnEdit)
DataSource.deepCloneOnEdit
for details of
what this means. If this value is not explicitly set, it defaults first to the value of DataBoundComponent.deepCloneOnEdit
, then to the value
of DataSource.deepCloneOnEdit
.
Like the other
deepCloneOnEdit
settings, this flag only has an effect if you are editing a values object that contains
nested objects or arrays, using dataPath
s.
Note : This is an advanced setting
deepCloneOnEdit
- New deepCloneOnEdit value. Default value is nullDataSourceField
instance, for chaining setter callsCanvas.setDataPath(java.lang.String)
,
FormItem.setDataPath(java.lang.String)
,
DataSource.setDeepCloneOnEdit(java.lang.Boolean)
public java.lang.Boolean getDeepCloneOnEdit()
DataSource.deepCloneOnEdit
for details of
what this means. If this value is not explicitly set, it defaults first to the value of DataBoundComponent.deepCloneOnEdit
, then to the value
of DataSource.deepCloneOnEdit
.
Like the other
deepCloneOnEdit
settings, this flag only has an effect if you are editing a values object that contains
nested objects or arrays, using dataPath
s.
Canvas.getDataPath()
,
FormItem.getDataPath()
,
DataSource.getDeepCloneOnEdit()
public DataSourceField setDefaultOperator(OperatorId defaultOperator)
If not specified, falls back to the default specified for the field's
data-type
.
defaultOperator
- New defaultOperator value. Default value is nullDataSourceField
instance, for chaining setter callsAdvancedFilter overview and related methods
public OperatorId getDefaultOperator()
If not specified, falls back to the default specified for the field's
data-type
.
AdvancedFilter overview and related methods
public DataSourceField setDetail(boolean detail)
DataBoundComponent
.
Detail fields won't be shown by default in a DataBoundComponent where DataBoundComponent.showDetailFields
is false. This
allows for some DataBound components, like a ListGrid
, to show a summary view
of records which displays only the most commonly viewed fields by default, while other DataBoundComponents, like a
DetailViewer
, show all fields by default.
In addition, the formItem.showIf
property is supported in multiple components
for conditional visibility - see for example ListGridField.showIf()
and FormItem.showIf()
).
detail
- New detail value. Default value is falseDataSourceField
instance, for chaining setter callsComponentBinding overview and related methods
public boolean getDetail()
DataBoundComponent
.
Detail fields won't be shown by default in a DataBoundComponent where DataBoundComponent.showDetailFields
is false. This
allows for some DataBound components, like a ListGrid
, to show a summary view
of records which displays only the most commonly viewed fields by default, while other DataBoundComponents, like a
DetailViewer
, show all fields by default.
In addition, the formItem.showIf
property is supported in multiple components
for conditional visibility - see for example ListGridField.showIf()
and FormItem.showIf()
).
ComponentBinding overview and related methods
public DataSourceField setDisplayField(java.lang.String displayField)
ListGrid
, the displayField
attribute may be used to cause some field to
display a value from another field in the record. This is typically used for editable foreignKey
fields. In this scenario, a dataSource field has a
foreignKey field which stores an ID value used to identify records in another, related dataSource. Rather than display
this ID to users, developers may wish to display another, user-friendly field from the related record. This is easy to
achieve by having a second field on the dataSource which will be populated with the "display value" from this related
dataSource, and using dataSourceField.displayField
to show this value. The includeFrom
feature handles populating this field
automatically for dataSources backed by the Smart GWT Server
. See
the "Editing included fields" section of the includeFrom
documentation for more on editing included foreignKey fields.
Editable dataSourceFields with a
specified displayField
and foreignKey
will typically be edited using a SelectItem
or ComboBoxItem
. In
this case, in addition to identifying the field to use as a static display value within the record being edited,
displayField
will also identify which field on the related dataSource to use as a display field when
showing a set of options to the user. This behavior may be modified in a couple of ways:
foreignDisplayField
attribute may be used to handle the
case where the name of the field used as a displayField within the dataSource is different from the name of the
included/equivalent field in the related dataSource.useLocalDisplayFieldValue
attribute may be
explicitly set to false to avoid picking up a display value from the local record altogether. Instead the
displayField will be used only to derive the display value from a related record from the optionDataSourceFormItem.displayField
.displayField
- New displayField value. Default value is nullDataSourceField
instance, for chaining setter callsDataSourceRelations overview and related methods
public java.lang.String getDisplayField()
ListGrid
, the displayField
attribute may be used to cause some field to
display a value from another field in the record. This is typically used for editable foreignKey
fields. In this scenario, a dataSource field has a
foreignKey field which stores an ID value used to identify records in another, related dataSource. Rather than display
this ID to users, developers may wish to display another, user-friendly field from the related record. This is easy to
achieve by having a second field on the dataSource which will be populated with the "display value" from this related
dataSource, and using dataSourceField.displayField
to show this value. The includeFrom
feature handles populating this field
automatically for dataSources backed by the Smart GWT Server
. See
the "Editing included fields" section of the includeFrom
documentation for more on editing included foreignKey fields.
Editable dataSourceFields with a
specified displayField
and foreignKey
will typically be edited using a SelectItem
or ComboBoxItem
. In
this case, in addition to identifying the field to use as a static display value within the record being edited,
displayField
will also identify which field on the related dataSource to use as a display field when
showing a set of options to the user. This behavior may be modified in a couple of ways:
foreignDisplayField
attribute may be used to handle the
case where the name of the field used as a displayField within the dataSource is different from the name of the
included/equivalent field in the related dataSource.useLocalDisplayFieldValue
attribute may be
explicitly set to false to avoid picking up a display value from the local record altogether. Instead the
displayField will be used only to derive the display value from a related record from the optionDataSourceFormItem.displayField
.DataSourceRelations overview and related methods
public DataSourceField setEmptyDisplayValue(java.lang.String emptyDisplayValue)
emptyDisplayValue
- New emptyDisplayValue value. Default value is nullDataSourceField
instance, for chaining setter callsFormItem.setEmptyDisplayValue(java.lang.String)
,
ListGridField.setEmptyCellValue(java.lang.String)
,
DetailViewerField.setEmptyCellValue(java.lang.String)
,
HTMLString
,
Appearance overview and related methods
public java.lang.String getEmptyDisplayValue()
FormItem.getEmptyDisplayValue()
,
ListGridField.getEmptyCellValue()
,
DetailViewerField.getEmptyCellValue()
,
HTMLString
,
Appearance overview and related methods
public DataSourceField setEscapeHTML(java.lang.Boolean escapeHTML)
If set, this property will be picked up by components bound to this dataSource, notifying them that any HTML characters should be escaped when displaying values for this field.
escapeHTML
- New escapeHTML value. Default value is nullDataSourceField
instance, for chaining setter callsListGridField.setEscapeHTML(java.lang.Boolean)
public java.lang.Boolean getEscapeHTML()
If set, this property will be picked up by components bound to this dataSource, notifying them that any HTML characters should be escaped when displaying values for this field.
ListGridField.getEscapeHTML()
public DataSourceField setExcludeFromState(java.lang.Boolean excludeFromState)
DataBoundComponent.getTitleField()
if DataBoundComponent.titleField
is not provided.excludeFromState
- New excludeFromState value. Default value is nullDataSourceField
instance, for chaining setter callspublic java.lang.Boolean getExcludeFromState()
DataBoundComponent.getTitleField()
if DataBoundComponent.titleField
is not provided.public DataSourceField setExportForceText(boolean exportForceText)
DataSource.recordsAsText()
, determines what
approach (if any) should be used to force values to be intepreted as text instead of heuristically parsed as dates,
times or other structured types.exportForceText
- New exportForceText value. Default value is falseDataSourceField
instance, for chaining setter callsTextExportSettings.setForceText(com.smartgwt.client.types.ForceTextApproach)
public boolean getExportForceText()
DataSource.recordsAsText()
, determines what
approach (if any) should be used to force values to be intepreted as text instead of heuristically parsed as dates,
times or other structured types.TextExportSettings.getForceText()
public DataSourceField setExportFormat(java.lang.String exportFormat)
FormatString
for this field, for use when exporting
data to spreadsheet formats (XLS and OOXML/XLSX),
XML, JSON or CSV. You can use this property to override the normal format
of this field, if any, specifically for exports, for both
server-based and client-driven exports. Note, for server-driven exports you can specify default formats for date,
time and datetime fields by specifying properties export.format.default.date
,
export.format.default.time
and export.format.default.datetime
in your
server.properties
file. Similarly, default formats for float and integer fields can be specified with
export.format.default.float
and export.format.default.integer
, respectively. These formats
will be used for fields that do not have a "format" or "exportFormat" property specified in the .ds.xml
file.
Specifically when exporting to spreadsheet formats, the FormatString
is translated to the type of
format string used by spreadsheet programs like Excel. A handful of features are not present in Excel format strings,
and some features behave slightly differently. These differences are explained below.
However, there is no such universal agreement when it come to rounding negative numbers. Some take the view that you should round by taking the number to the larger absolute value, so -7.15 becomes -7.2. Others feel that you should round by taking the number to the larger value in the sense of it being "less negative", so -7.15 becomes -7.1.
Smart GWT formatting takes the first approach and rounds negative numbers away from zero. We do this simply because that is what Java DecimalFormat does. Unfortunately, Excel does the opposite. Therefore, you will see rounding differences on negative numbers on exact 50% boundaries: Smart GWT will format -7.15 as -7.2, while Excel will format the same value as -7.1.
Known differences in behavior in edge cases include:
exportFormat
, with the
intent of exporting your values in a way that is similar to your application formatting (which would be specified with
the format
property), but within the confines of what Excel
supports.
FormatStrings
. If you do hit the limit, the only workaround is to use
fewer unique FormatStrings
.
You might expect that we would give Excel both the formatted value and the numeric value, but this is only possible by creating what's called a "custom format" for that cell, which as the section above mentions, is limited in that only a few hundred can be created.
With this Excel limitation in mind, it makes sense to just go with the default behavior.
If you decide otherwise, one option is to use exportNumbersAsFormattedString
, but see the docs
for that property for the drawbacks of doing this.
exportFormat
- New exportFormat value. Default value is nullDataSourceField
instance, for chaining setter callssetFormat(java.lang.String)
,
FormatString
public java.lang.String getExportFormat()
FormatString
for this field, for use when exporting
data to spreadsheet formats (XLS and OOXML/XLSX),
XML, JSON or CSV. You can use this property to override the normal format
of this field, if any, specifically for exports, for both
server-based and client-driven exports. Note, for server-driven exports you can specify default formats for date,
time and datetime fields by specifying properties export.format.default.date
,
export.format.default.time
and export.format.default.datetime
in your
server.properties
file. Similarly, default formats for float and integer fields can be specified with
export.format.default.float
and export.format.default.integer
, respectively. These formats
will be used for fields that do not have a "format" or "exportFormat" property specified in the .ds.xml
file.
Specifically when exporting to spreadsheet formats, the FormatString
is translated to the type of
format string used by spreadsheet programs like Excel. A handful of features are not present in Excel format strings,
and some features behave slightly differently. These differences are explained below.
However, there is no such universal agreement when it come to rounding negative numbers. Some take the view that you should round by taking the number to the larger absolute value, so -7.15 becomes -7.2. Others feel that you should round by taking the number to the larger value in the sense of it being "less negative", so -7.15 becomes -7.1.
Smart GWT formatting takes the first approach and rounds negative numbers away from zero. We do this simply because that is what Java DecimalFormat does. Unfortunately, Excel does the opposite. Therefore, you will see rounding differences on negative numbers on exact 50% boundaries: Smart GWT will format -7.15 as -7.2, while Excel will format the same value as -7.1.
Known differences in behavior in edge cases include:
exportFormat
, with the
intent of exporting your values in a way that is similar to your application formatting (which would be specified with
the format
property), but within the confines of what Excel
supports.
FormatStrings
. If you do hit the limit, the only workaround is to use
fewer unique FormatStrings
.
You might expect that we would give Excel both the formatted value and the numeric value, but this is only possible by creating what's called a "custom format" for that cell, which as the section above mentions, is limited in that only a few hundred can be created.
With this Excel limitation in mind, it makes sense to just go with the default behavior.
If you decide otherwise, one option is to use exportNumbersAsFormattedString
, but see the docs
for that property for the drawbacks of doing this.
getFormat()
,
FormatString
public DataSourceField setExportTitle(java.lang.String exportTitle)
exportTitle
- New exportTitle value. Default value is nullDataSourceField
instance, for chaining setter callspublic java.lang.String getExportTitle()
public DataSourceField setForeignDisplayField(java.lang.String foreignDisplayField)
foreignKey
relationship
exists.
For a general overview on picking up display values from a separate field,
see displayField
property.
The foreignDisplayField
property is useful for editable fields, where the
name of the display field within the record being edited differs from the display field
for related records in the option dataSource.
For example consider a "countryDS" dataSource with the following fields:
<field name="id" type="sequence" hidden="true" primaryKey="true" /> <field name="name" type="text" title="Country" required="true" />...and a "city" dataSource which uses a foreignKey relationship identify associated country records:
<field name="id" type="sequence" hidden="true" primaryKey="true" /> <field name="name" type="text" title="City" required="true" /> <field name="countryId" type="integer" editorType="SelectItem" foreignKey="countryDS.id" displayField="countryName" foreignDisplayField="name" title="Country" /> <field name="countryName" includeFrom="countryDS.name" hidden="true" />A DynamicForm bound to this "city" dataSource would display a SelectItem editor by default for the country field. The initial display value would be the local value from the "countryName" field, populated from the related countryDS automatically via the
includeFrom
feature.
Note that when specified, foreignDisplayField
is always expected to be set to
the related dataSource field containing equivalent values to the displayField
in the local dataSource. This is important as, when editing the field, foreignDisplayField values from
the related dataSource will be displayed to the user, and when a value is selected
the local record's displayField
value will be updated to match the selected
foreignDisplayField
value from the related dataSource's record. This behavior
is documented under FormItem.displayField
.
foreignDisplayField
- New foreignDisplayField value. Default value is nullDataSourceField
instance, for chaining setter callsDataSourceRelations overview and related methods
public java.lang.String getForeignDisplayField()
foreignKey
relationship
exists.
For a general overview on picking up display values from a separate field,
see displayField
property.
The foreignDisplayField
property is useful for editable fields, where the
name of the display field within the record being edited differs from the display field
for related records in the option dataSource.
For example consider a "countryDS" dataSource with the following fields:
<field name="id" type="sequence" hidden="true" primaryKey="true" /> <field name="name" type="text" title="Country" required="true" />...and a "city" dataSource which uses a foreignKey relationship identify associated country records:
<field name="id" type="sequence" hidden="true" primaryKey="true" /> <field name="name" type="text" title="City" required="true" /> <field name="countryId" type="integer" editorType="SelectItem" foreignKey="countryDS.id" displayField="countryName" foreignDisplayField="name" title="Country" /> <field name="countryName" includeFrom="countryDS.name" hidden="true" />A DynamicForm bound to this "city" dataSource would display a SelectItem editor by default for the country field. The initial display value would be the local value from the "countryName" field, populated from the related countryDS automatically via the
includeFrom
feature.
Note that when specified, foreignDisplayField
is always expected to be set to
the related dataSource field containing equivalent values to the displayField
in the local dataSource. This is important as, when editing the field, foreignDisplayField values from
the related dataSource will be displayed to the user, and when a value is selected
the local record's displayField
value will be updated to match the selected
foreignDisplayField
value from the related dataSource's record. This behavior
is documented under FormItem.displayField
.
DataSourceRelations overview and related methods
public DataSourceField setForeignKey(java.lang.String foreignKey)
The format of foreignKey
is
dataSourceId.fieldName
.
For a foreignKey within the same dataSource, you can omit the dataSourceId
and just specify fieldName
. For example, to create a tree relationship
within a DataSource:
DataSource supplyItem = new DataSource(); DataSourceField itemId = new DataSourceField(); itemId.setType(FieldType.SEQUENCE); itemId.setPrimaryKey(true); DataSourceField parentId = new DataSourceField(); parentId.setType(FieldType.INTEGER); parentId.setForeignKey("itemId"); supplyItem.setFields(itemId, parentId);
foreignKey
declarations also allow other automatic behaviors by
DataBoundComponents
, such as ListGrid.fetchRelatedData()
.
For SQLDataSources foreign keys can be automatically discovered from SQL tables if
autoDeriveSchema
is set.
foreignKey
- New foreignKey value. Default value is falseDataSourceField
instance, for chaining setter callsDataSourceField.joinType
,
DataSourceRelations overview and related methods
public java.lang.String getForeignKey()
The format of foreignKey
is
dataSourceId.fieldName
.
For a foreignKey within the same dataSource, you can omit the dataSourceId
and just specify fieldName
. For example, to create a tree relationship
within a DataSource:
DataSource supplyItem = new DataSource(); DataSourceField itemId = new DataSourceField(); itemId.setType(FieldType.SEQUENCE); itemId.setPrimaryKey(true); DataSourceField parentId = new DataSourceField(); parentId.setType(FieldType.INTEGER); parentId.setForeignKey("itemId"); supplyItem.setFields(itemId, parentId);
foreignKey
declarations also allow other automatic behaviors by
DataBoundComponents
, such as ListGrid.fetchRelatedData()
.
For SQLDataSources foreign keys can be automatically discovered from SQL tables if
autoDeriveSchema
is set.
DataSourceField.joinType
,
DataSourceRelations overview and related methods
public DataSourceField setFormat(java.lang.String format)
DataBoundComponent
or when
exporting via DataSource.exportData()
or ListGrid.exportData()
or ListGrid.exportClientData()
. Supported for fields of
type "date", "time", "datetime", "int", "float" or any derived SimpleType
.
To
configure a different format for export, use exportFormat
.
This is a per-field setting; you can alternatively set a default format for all "date", "time" or
"datetime" fields via DateUtil.setNormalDatetimeDisplayFormat()
and related methods on com.smartgwt.client.util.Date
. See also
LocalizedNumberFormatting
for built-in FieldTypes
that handle localized currency formatting.
Also note, this property takes precedence over any specified
dateFormatter
, but can be overridden on a
per-component basis by providing a formatter directly on the component, for example, via ListGrid.setCellFormatter()
or FormItem.formatValue()
.
format
- New format value. Default value is nullDataSourceField
instance, for chaining setter callssetExportFormat(java.lang.String)
,
FormatString
public java.lang.String getFormat()
DataBoundComponent
or when
exporting via DataSource.exportData()
or ListGrid.exportData()
or ListGrid.exportClientData()
. Supported for fields of
type "date", "time", "datetime", "int", "float" or any derived SimpleType
.
To
configure a different format for export, use exportFormat
.
This is a per-field setting; you can alternatively set a default format for all "date", "time" or
"datetime" fields via DateUtil.setNormalDatetimeDisplayFormat()
and related methods on com.smartgwt.client.util.Date
. See also
LocalizedNumberFormatting
for built-in FieldTypes
that handle localized currency formatting.
Also note, this property takes precedence over any specified
dateFormatter
, but can be overridden on a
per-component basis by providing a formatter directly on the component, for example, via ListGrid.setCellFormatter()
or FormItem.formatValue()
.
getExportFormat()
,
FormatString
public DataSourceField setGroup(java.lang.String group)
ComponentSchema
, indicates what group to place the property in when editing
in Visual Builder.group
- New group value. Default value is nullDataSourceField
instance, for chaining setter callsComponentSchema overview and related methods
public java.lang.String getGroup()
ComponentSchema
, indicates what group to place the property in when editing
in Visual Builder.ComponentSchema overview and related methods
public DataSourceField setHidden(boolean hidden)
See detail
for fields that should be hidden in a summary view such as a ListGrid
,
but still available to the user.
NOTE: This property is not a security setting - data for hidden
fields is still delivered to the client, it just isn't shown to the user. If you wish to make sure that only
appropriate data reaches the client, use OperationBinding.outputs
, canView
:false on the field, or a
field-level declarative security setting like viewRequiresRole
.
hidden
- New hidden value. Default value is falseDataSourceField
instance, for chaining setter callsComponentBinding overview and related methods
public boolean getHidden()
See detail
for fields that should be hidden in a summary view such as a ListGrid
,
but still available to the user.
NOTE: This property is not a security setting - data for hidden
fields is still delivered to the client, it just isn't shown to the user. If you wish to make sure that only
appropriate data reaches the client, use OperationBinding.outputs
, canView
:false on the field, or a
field-level declarative security setting like viewRequiresRole
.
ComponentBinding overview and related methods
public DataSourceField setIgnoreTextMatchStyle(java.lang.Boolean ignoreTextMatchStyle)
clientOnly
DataSources and the
built-in SQL
, JPA
and
Hibernate
DataSources available in Pro, Power and Enterprise
versions of Smart GWT. Use this flag to inhibit the normal use of TextMatchStyle
for this field. A field with this flag set will always be tested for exact equality in generated queries, even for
filter-style queries where normal behavior would be to use a substring match or similar.
Whether or not the exact
match is case-sensitive is determined by the DataSource's ignoreTextMatchStyleCaseSensitive
setting.
ignoreTextMatchStyle
- New ignoreTextMatchStyle value. Default value is nullDataSourceField
instance, for chaining setter callspublic java.lang.Boolean getIgnoreTextMatchStyle()
clientOnly
DataSources and the
built-in SQL
, JPA
and
Hibernate
DataSources available in Pro, Power and Enterprise
versions of Smart GWT. Use this flag to inhibit the normal use of TextMatchStyle
for this field. A field with this flag set will always be tested for exact equality in generated queries, even for
filter-style queries where normal behavior would be to use a substring match or similar.
Whether or not the exact
match is case-sensitive is determined by the DataSource's ignoreTextMatchStyleCaseSensitive
setting.
public DataSourceField setInapplicable(java.lang.Boolean inapplicable)
ComponentSchema
, a field inherited
from another schema can be redeclared with this property
set in order to indicate that the property should not be used. This is primarily used to influence VisualBuilder
. For simple type properties, this avoids the property appearing in the
Component Editor.
For fields that hold subcomponents, this prevents inappropriate drag and drop. For example, a
custom class called MyDialog
may automatically create a series of children, and not allow arbitrary other
children to be added. In this case, the inherited property Canvas.children
should be marked inapplicable in order to prevent arbitrary components being dropped onto a
MyDialog
instance.
inapplicable
- New inapplicable value. Default value is nullDataSourceField
instance, for chaining setter callsComponentSchema overview and related methods
public java.lang.Boolean getInapplicable()
ComponentSchema
, a field inherited
from another schema can be redeclared with this property
set in order to indicate that the property should not be used. This is primarily used to influence VisualBuilder
. For simple type properties, this avoids the property appearing in the
Component Editor.
For fields that hold subcomponents, this prevents inappropriate drag and drop. For example, a
custom class called MyDialog
may automatically create a series of children, and not allow arbitrary other
children to be added. In this case, the inherited property Canvas.children
should be marked inapplicable in order to prevent arbitrary components being dropped onto a
MyDialog
instance.
ComponentSchema overview and related methods
public DataSourceField setJoinPrefix(java.lang.String joinPrefix)
Server
summaries
feature and the summary function
is "concat".joinPrefix
- New joinPrefix value. Default value is nullDataSourceField
instance, for chaining setter callssetJoinString(java.lang.String)
,
setJoinSuffix(java.lang.String)
,
com.smartgwt.client.types.SummaryFunction
,
ServerSummaries overview and related methods
public java.lang.String getJoinPrefix()
Server
summaries
feature and the summary function
is "concat".getJoinString()
,
getJoinSuffix()
,
com.smartgwt.client.types.SummaryFunction
,
ServerSummaries overview and related methods
public DataSourceField setJoinString(java.lang.String joinString)
Server summaries
feature and the summary function
is "concat".
The default value is ", ".joinString
- New joinString value. Default value is nullDataSourceField
instance, for chaining setter callssetJoinPrefix(java.lang.String)
,
setJoinSuffix(java.lang.String)
,
com.smartgwt.client.types.SummaryFunction
,
ServerSummaries overview and related methods
public java.lang.String getJoinString()
Server summaries
feature and the summary function
is "concat".
The default value is ", ".getJoinPrefix()
,
getJoinSuffix()
,
com.smartgwt.client.types.SummaryFunction
,
ServerSummaries overview and related methods
public DataSourceField setJoinSuffix(java.lang.String joinSuffix)
Server
summaries
feature and the summary function
is "concat".joinSuffix
- New joinSuffix value. Default value is nullDataSourceField
instance, for chaining setter callssetJoinPrefix(java.lang.String)
,
setJoinString(java.lang.String)
,
com.smartgwt.client.types.SummaryFunction
,
ServerSummaries overview and related methods
public java.lang.String getJoinSuffix()
Server
summaries
feature and the summary function
is "concat".getJoinPrefix()
,
getJoinString()
,
com.smartgwt.client.types.SummaryFunction
,
ServerSummaries overview and related methods
public DataSourceField setLength(java.lang.Integer length)
length range validator
will be automatically generated on both the client and
server side to enforce this maximum length (unless such a validator is explicitly present for the field already).
The TextItem.enforceLength
attribute can also
explicitly limit user input for freeform text items editing fields with an explicit length specified.
NOTE:
For DataSources of type "sql", this property has a bearing on the type of column we use when the underlying table is
created by a DataSource import
in the Admin Console
. Below a certain length (which is database-specific, see below),
we use standard VARCHAR
columns; above that length, we use an alternate strategy (again,
database-specific). For these long fields, we sometimes also generate different SQL for "update" and "add"
operations, using JDBC "?" replacement parameters rather than embedding values directly in the generated SQL; whether
or not this is done depends entirely on what the underlying database product and/or JDBC driver will allow.
Table of field length limits for supported databases:
Database product | VARCHAR limit * | Type used above limit |
HSQLDB | None | - |
IBM DB2 | 4000 | CLOB |
Firebird | 32767 | BLOB with subtype 1 |
Informix | 255 / 32739 | LVARCHAR / TEXT ** |
Microsoft SQL Server | 8000 | TEXT |
MySQL | 255 / 65535 / 16M | TEXT / MEDIUMTEXT / LONGTEXT *** |
MariaDB | 255 / 65535 / 16M | TEXT / MEDIUMTEXT / LONGTEXT *** |
Oracle | 4000 | CLOB |
PostgreSQL | 4000 | TEXT |
** Informix has a limit of just 255 characters for VARCHAR, but has a native LVARCHAR type which supports nearly 32K characters without needing to fall back on long datatypes. Therefore, with that one product, we have two thresholds for a change in storage type.
*** MySQL has a limit of 255 characters for VARCHAR, 65,535 characters for TEXT and 16,777,215 for MEDIUMTEXT; therefore, with that one product, we have three thresholds for a change in storage type.
length
- New length value. Default value is nullDataSourceField
instance, for chaining setter callsListGridField.setWidth(int)
,
Long Text Examplepublic java.lang.Integer getLength()
length range validator
will be automatically generated on both the client and
server side to enforce this maximum length (unless such a validator is explicitly present for the field already).
The TextItem.enforceLength
attribute can also
explicitly limit user input for freeform text items editing fields with an explicit length specified.
NOTE:
For DataSources of type "sql", this property has a bearing on the type of column we use when the underlying table is
created by a DataSource import
in the Admin Console
. Below a certain length (which is database-specific, see below),
we use standard VARCHAR
columns; above that length, we use an alternate strategy (again,
database-specific). For these long fields, we sometimes also generate different SQL for "update" and "add"
operations, using JDBC "?" replacement parameters rather than embedding values directly in the generated SQL; whether
or not this is done depends entirely on what the underlying database product and/or JDBC driver will allow.
Table of field length limits for supported databases:
Database product | VARCHAR limit * | Type used above limit |
HSQLDB | None | - |
IBM DB2 | 4000 | CLOB |
Firebird | 32767 | BLOB with subtype 1 |
Informix | 255 / 32739 | LVARCHAR / TEXT ** |
Microsoft SQL Server | 8000 | TEXT |
MySQL | 255 / 65535 / 16M | TEXT / MEDIUMTEXT / LONGTEXT *** |
MariaDB | 255 / 65535 / 16M | TEXT / MEDIUMTEXT / LONGTEXT *** |
Oracle | 4000 | CLOB |
PostgreSQL | 4000 | TEXT |
** Informix has a limit of just 255 characters for VARCHAR, but has a native LVARCHAR type which supports nearly 32K characters without needing to fall back on long datatypes. Therefore, with that one product, we have two thresholds for a change in storage type.
*** MySQL has a limit of 255 characters for VARCHAR, 65,535 characters for TEXT and 16,777,215 for MEDIUMTEXT; therefore, with that one product, we have three thresholds for a change in storage type.
ListGridField.getWidth()
,
Long Text Examplepublic DataSourceField setLenientXPath(java.lang.Boolean lenientXPath)
valueXPath
for this field should
not perform any validation at all and will return null for non existing XPaths. Otherwise warning message will be logged
for non-existing XPath or with null objects in the middle of XPath. NOTE: this applies to server-side processing of valueXPath only.
lenientXPath
- New lenientXPath value. Default value is nullDataSourceField
instance, for chaining setter callspublic java.lang.Boolean getLenientXPath()
valueXPath
for this field should
not perform any validation at all and will return null for non existing XPaths. Otherwise warning message will be logged
for non-existing XPath or with null objects in the middle of XPath. NOTE: this applies to server-side processing of valueXPath only.
public DataSourceField setMultiple(java.lang.Boolean multiple)
XML or JSON data
is singular, it will be wrapped in an Array.
JPA and Hibernate DataSources use multiple:true
as part of the declaration of
One-To-Many and Many-to-Many relations - see JpaHibernateRelations
for details.
For simple Criteria, the criteria value is compared to each field value in the
multiple:true
field, according to the
textMatchStyle
. If any field value matches the
j filter value, the field is considered to match the criteria.
For AdvancedCriteria
, for normal search
operators
the field
value is considered as matching the Criterion
if any of the field values
match the Criterion. Specifically, this is true of all operators that have an
operatorValueType
of "fieldType" or "valueRange".
For operators that compare against other fields in same record, such as "equalsField",
if the other field is not multiple:true
, matching works the same as for
normal operators, that is, as if criterion.value
directly contained the value
rather than the name of another field.
If the other field is also multiple:true, only "equalsField", "notEqualsField",
"iEqualsField" and "iNotEqualsField" are allowed (any other operator
will
cause a warning and be ignored) and the set of values in the field must be identical (aside
from case, for operators prefixed with "i") and in identical order to match.
For the inSet
operator, the field matches if there is any intersection between
the field values and the array of values provided in criterion.value
.
notInSet
is the reverse.
Finally, for "isBlank", "notBlank", "isNull" and "notNull", an empty Array is considered non-null. For example,
if you use dataFormat:"json" and the field value is provided to the browser as
[]
(JSON for an empty Array), the field is considered non-null.
Values for multiple:true fields appear as Java Lists when received in server code such as a
DMI. The Smart GWT Server supports simple storage of values that are multiple:true, controlled
via the multipleStorage
setting.
For server-side behavior of JPA and Hibernate relation fields that are multiple:true, see
JpaHibernateRelations
.
For non-relation fields, the Smart GWT Server supports simple storage of values that are
multiple:true, controlled via the multipleStorage
setting, with some limited support
for server-side filtering, as described in the multipleStorage
docs.
For the built-in SQL, Hibernate and JPA connectors, if criteria are specified for a
multiple:true field where multipleStorage
is null or "none", the Smart GWT
server knows nothing about how the multiple values are stored, so as a fallback the criteria
will operate as though the field were a normal, non-multiple "text" field. This will
generally not match the client-side filtering behavior described above, so filtering
should either be performed entirely on the client (for example, via
dataFetchMode:"local"
or entirely on the server (via
ResultSet.useClientFiltering
:"false")
The server-side filtering is done through a criteria transform which happens with
transformMultipleFields
.
Specifically for XML serialization and deserialization, multiple:true
behaves
similarly to the
SOAP array idiom, that is,
there will be a "wrapper element" named after the field name, whose contents will be several
elements of the specified field.type
.
For example, Layout.members
is declared with
type:"Canvas",
multiple:true
. The correct XML format is thus:
<VLayout> <members> <Canvas ID="myCanvas" ... /> <ListGrid ID="myGrid" .../> <Toolstrip ID="myToolStrip" ... /> </members> </VLayout>
See childTagName
for customizing the tagName used for
subelements.
multiple
- New multiple value. Default value is falseDataSourceField
instance, for chaining setter callsComponentSchema overview and related methods
public java.lang.Boolean getMultiple()
XML or JSON data
is singular, it will be wrapped in an Array.
JPA and Hibernate DataSources use multiple:true
as part of the declaration of
One-To-Many and Many-to-Many relations - see JpaHibernateRelations
for details.
For simple Criteria, the criteria value is compared to each field value in the
multiple:true
field, according to the
textMatchStyle
. If any field value matches the
j filter value, the field is considered to match the criteria.
For AdvancedCriteria
, for normal search
operators
the field
value is considered as matching the Criterion
if any of the field values
match the Criterion. Specifically, this is true of all operators that have an
operatorValueType
of "fieldType" or "valueRange".
For operators that compare against other fields in same record, such as "equalsField",
if the other field is not multiple:true
, matching works the same as for
normal operators, that is, as if criterion.value
directly contained the value
rather than the name of another field.
If the other field is also multiple:true, only "equalsField", "notEqualsField",
"iEqualsField" and "iNotEqualsField" are allowed (any other operator
will
cause a warning and be ignored) and the set of values in the field must be identical (aside
from case, for operators prefixed with "i") and in identical order to match.
For the inSet
operator, the field matches if there is any intersection between
the field values and the array of values provided in criterion.value
.
notInSet
is the reverse.
Finally, for "isBlank", "notBlank", "isNull" and "notNull", an empty Array is considered non-null. For example,
if you use dataFormat:"json" and the field value is provided to the browser as
[]
(JSON for an empty Array), the field is considered non-null.
Values for multiple:true fields appear as Java Lists when received in server code such as a
DMI. The Smart GWT Server supports simple storage of values that are multiple:true, controlled
via the multipleStorage
setting.
For server-side behavior of JPA and Hibernate relation fields that are multiple:true, see
JpaHibernateRelations
.
For non-relation fields, the Smart GWT Server supports simple storage of values that are
multiple:true, controlled via the multipleStorage
setting, with some limited support
for server-side filtering, as described in the multipleStorage
docs.
For the built-in SQL, Hibernate and JPA connectors, if criteria are specified for a
multiple:true field where multipleStorage
is null or "none", the Smart GWT
server knows nothing about how the multiple values are stored, so as a fallback the criteria
will operate as though the field were a normal, non-multiple "text" field. This will
generally not match the client-side filtering behavior described above, so filtering
should either be performed entirely on the client (for example, via
dataFetchMode:"local"
or entirely on the server (via
ResultSet.useClientFiltering
:"false")
The server-side filtering is done through a criteria transform which happens with
transformMultipleFields
.
Specifically for XML serialization and deserialization, multiple:true
behaves
similarly to the
SOAP array idiom, that is,
there will be a "wrapper element" named after the field name, whose contents will be several
elements of the specified field.type
.
For example, Layout.members
is declared with
type:"Canvas",
multiple:true
. The correct XML format is thus:
<VLayout> <members> <Canvas ID="myCanvas" ... /> <ListGrid ID="myGrid" .../> <Toolstrip ID="myToolStrip" ... /> </members> </VLayout>
See childTagName
for customizing the tagName used for
subelements.
ComponentSchema overview and related methods
public DataSourceField setMultipleValueSeparator(java.lang.String multipleValueSeparator)
multiple:true
, the separator used
between values when they are displayed.multipleValueSeparator
- New multipleValueSeparator value. Default value is ", "DataSourceField
instance, for chaining setter callspublic java.lang.String getMultipleValueSeparator()
multiple:true
, the separator used
between values when they are displayed.public DataSourceField setName(java.lang.String name)
Must be unique across all fields within the DataSource as well as a valid JavaScript
identifier - see FieldName
for details and how to check for validity.
The field name is also the property in each DataSource record which holds the value for this field.
name
- New name value. Default value is nullDataSourceField
instance, for chaining setter callsFieldName
,
Basics overview and related methods
public java.lang.String getName()
Must be unique across all fields within the DataSource as well as a valid JavaScript
identifier - see FieldName
for details and how to check for validity.
The field name is also the property in each DataSource record which holds the value for this field.
FieldName
,
Basics overview and related methods
public DataSourceField setNillable(java.lang.Boolean nillable)
xsi:nil
being used to transmit the value when serializing
to XML, like so:
<book> <title>Beowulf</title> <author xsi:nil="true"/> </book>If
nillable
is not set, no XML element will be generated for
the explicit null value.nillable
- New nillable value. Default value is nullDataSourceField
instance, for chaining setter callspublic java.lang.Boolean getNillable()
xsi:nil
being used to transmit the value when serializing
to XML, like so:
<book> <title>Beowulf</title> <author xsi:nil="true"/> </book>If
nillable
is not set, no XML element will be generated for
the explicit null value.public DataSourceField setPrecision(java.lang.Integer precision)
For example, a field value of 343.1, 343.104 and 343.09872677 would all be shown as 343.10 if precision is 5.
The original value is always shown when the value is edited.
precision
- New precision value. Default value is nullDataSourceField
instance, for chaining setter callsAppearance overview and related methods
public java.lang.Integer getPrecision()
For example, a field value of 343.1, 343.104 and 343.09872677 would all be shown as 343.10 if precision is 5.
The original value is always shown when the value is edited.
Appearance overview and related methods
public DataSourceField setPrimaryKey(boolean primaryKey)
primaryKey
field per DataSource, and ideally this field should be of type
"sequence". If you have control of the underlying tables, there
is nothing to stop you from adding a field like this (a so-called "synthetic" or "surrogate" key), even for tables that
already have a set of columns that could combine to make a composite key (a so-called "natural" key). Also, it is
neither necessary nor correct to use a composite primaryKey because you want to enforce uniqueness across that
combination of fields. You can achieve that by declaring a unique constraint in the table schema, or use an isUnique
validator with validator.criteriaFields
, or both; there
is no need to use a composite key to enforce uniqueness Note that composite primaryKeys are not supported in
tree-structured datasets (Tree
and ResultTree
) or components (TreeGrid
, ColumnTree
). Tree-structured data requires that nodes have a unique idField
, with the parent/child relationship expressed through the
parentIdField
. This implies that binding a Tree to a
DataSource requires that the DataSource have a singular primaryKey, and that the primaryKey field is also the idField,
as described in the tree databinding overview
A DataSource that can
only perform the "fetch" operation does not require a primaryKey unless it contains binary fields
. If a DataSource allows modification of DataSource records
through add, update and remove DataSource operations, or it contains one or more binary fields, one or more fields must
be marked as the primary key.
Smart GWT requires a primary key value to uniquely identify records when communicating updates or deletions to the server. There is no requirement that the primaryKey field be mapped to an actual "primary key" in your object model, web service, or database (though this is the most obvious and natural thing to do, of course). The only requirement is that the combined values of the primaryKey fields be unique for a given browser instance for the lifetime of the page.
If using Smart GWT's SQL engine
and generating SQL tables using the Database Configuration
Tool
, the table column generated from a primaryKey field will have a unique constraint applied in the database table
and, if the field is of type "sequence", the database column will also be created as an "identity column" in those
databases that implement sequence-type handling with identity columns.
primaryKey
- New primaryKey value. Default value is falseDataSourceField
instance, for chaining setter callsDataSourceRelations overview and related methods
public boolean getPrimaryKey()
primaryKey
field per DataSource, and ideally this field should be of type
"sequence". If you have control of the underlying tables, there
is nothing to stop you from adding a field like this (a so-called "synthetic" or "surrogate" key), even for tables that
already have a set of columns that could combine to make a composite key (a so-called "natural" key). Also, it is
neither necessary nor correct to use a composite primaryKey because you want to enforce uniqueness across that
combination of fields. You can achieve that by declaring a unique constraint in the table schema, or use an isUnique
validator with validator.criteriaFields
, or both; there
is no need to use a composite key to enforce uniqueness Note that composite primaryKeys are not supported in
tree-structured datasets (Tree
and ResultTree
) or components (TreeGrid
, ColumnTree
). Tree-structured data requires that nodes have a unique idField
, with the parent/child relationship expressed through the
parentIdField
. This implies that binding a Tree to a
DataSource requires that the DataSource have a singular primaryKey, and that the primaryKey field is also the idField,
as described in the tree databinding overview
A DataSource that can
only perform the "fetch" operation does not require a primaryKey unless it contains binary fields
. If a DataSource allows modification of DataSource records
through add, update and remove DataSource operations, or it contains one or more binary fields, one or more fields must
be marked as the primary key.
Smart GWT requires a primary key value to uniquely identify records when communicating updates or deletions to the server. There is no requirement that the primaryKey field be mapped to an actual "primary key" in your object model, web service, or database (though this is the most obvious and natural thing to do, of course). The only requirement is that the combined values of the primaryKey fields be unique for a given browser instance for the lifetime of the page.
If using Smart GWT's SQL engine
and generating SQL tables using the Database Configuration
Tool
, the table column generated from a primaryKey field will have a unique constraint applied in the database table
and, if the field is of type "sequence", the database column will also be created as an "identity column" in those
databases that implement sequence-type handling with identity columns.
DataSourceRelations overview and related methods
public DataSourceField setPropertiesOnly(java.lang.Boolean propertiesOnly)
ComponentSchema
for fields that contain other components, this flag
suppresses auto-construction for subcomponents that appear under this field.
For example, the VLayout
schema sets this for its members
property, so that when a VLayout is constructed via XML as follows:
<VLayout> <members> <ListGrid ID="myGrid" .../> <Toolstrip ID="myToolStrip" ... /> </members> </VLayout>The ListGrid and ToolStrip do not construct themselves automatically. Instead, the VLayout receives the properties of the ListGrid and ToolStrip as ordinary JavaScript Objects, with the special property
_constructor
set to the name of the class that should be
constructed.propertiesOnly
- New propertiesOnly value. Default value is nullDataSourceField
instance, for chaining setter callsComponentSchema overview and related methods
public java.lang.Boolean getPropertiesOnly()
ComponentSchema
for fields that contain other components, this flag
suppresses auto-construction for subcomponents that appear under this field.
For example, the VLayout
schema sets this for its members
property, so that when a VLayout is constructed via XML as follows:
<VLayout> <members> <ListGrid ID="myGrid" .../> <Toolstrip ID="myToolStrip" ... /> </members> </VLayout>The ListGrid and ToolStrip do not construct themselves automatically. Instead, the VLayout receives the properties of the ListGrid and ToolStrip as ordinary JavaScript Objects, with the special property
_constructor
set to the name of the class that should be
constructed.ComponentSchema overview and related methods
public DataSourceField setRequired(boolean required)
"required" validator
.
Note that required
should not be set for a server-generated field, such as a
sequence, or validation will fail on the client.
applyWhen
condition to a
required
validator introduces subtle complexities to the process of validating an existing record.
The client is not guaranteed to know the the full and complete state of the record it is
editing because it is common for a DynamicForm
to be editing a subset of
fields. When a field is unconditionally required, things are simple: if the
DynamicForm has a FormItem
for that field, then the
required
validation
passes if that FormItem has a value, and fails if it does not. If the form has no FormItem
for the field, it can assume that the field has a value because otherwise it would have
failed validation when we attempted to add it (when we are adding a record, we of course do
know the full and complete state of the record - it is whatever we are about to add).
When a field is conditionally required, the client can no longer assume that all required fields will have a value. It may be the case that the condition of requirement was not met when the record was added, but now it is. For example, consider these field definitions:
<field name="yearsAtCurrentAddress" type="integer" /> <field name="previousAddress" type="text" > <validator type="required" errorMessage="Previous address is required if you have been at your current address less than three years"> <applyWhen operator="and"> <criteria> <criterion fieldName="yearsAtCurrentAddress" operator="lessThan" value="3" /> </criteria> </applyWhen> </validator> </field>Imagine a record for this DataSource is added where the user has entered a value of "3" for "yearsAtCurrentAddress", and no previous address. Later, the value of that field is changed to "2". If this is done using a form that is also showing the "previousAddress" field, we will know that "previousAddress" has not been provided, so we can fail the validation and the user will get a helpful error message explaining what the problem is.
However, if the form does not also show the "previousAddress" field, we may choose to use an
OperationBinding
that uses outputs
to trim the
record down to just the fields the form does contain, in the interests of avoiding
information leakage. Or perhaps that value is automatically culled from the record before
the client sees it by the application of a declarative security rule
.
Whatever the reason, if the client does not have the complete record, it is not possible
for the client to sensibly apply this validation. And because the client has no way of
knowing if a value is missing because it is genuinely null, or because it has been trimmed
away by the server, we must treat any null value with suspicion (unless it has a matching
FormItem - the presence of the FormItem means that the user can edit the value, so it
would make no sense to pair it with a trimmed record that excludes that field value).
When this happens, we mark the validation as having passed on the client, but in need of
running on the server. The server validation makes use of the "storedRecord" facility
(look for the description of $storedRecord in the
Velocity support overview
) to overlay the changed record on
top of the existing record as it currently exists in the database. This gives the validator
the complete record including both changed and unchanged values, so it is able to carry
out the required check in a meaningful way. However, you should be aware that the
combination of conditional "required" validators and DynamicForms that edit partial
records can result in a validation that cannot run on the client and must do both a server
roundtrip and a database fetch.
required
- New required value. Default value is falseDataSourceField
instance, for chaining setter callsValidator.setApplyWhen(com.smartgwt.client.data.AdvancedCriteria)
public boolean getRequired()
"required" validator
.
Note that required
should not be set for a server-generated field, such as a
sequence, or validation will fail on the client.
applyWhen
condition to a
required
validator introduces subtle complexities to the process of validating an existing record.
The client is not guaranteed to know the the full and complete state of the record it is
editing because it is common for a DynamicForm
to be editing a subset of
fields. When a field is unconditionally required, things are simple: if the
DynamicForm has a FormItem
for that field, then the
required
validation
passes if that FormItem has a value, and fails if it does not. If the form has no FormItem
for the field, it can assume that the field has a value because otherwise it would have
failed validation when we attempted to add it (when we are adding a record, we of course do
know the full and complete state of the record - it is whatever we are about to add).
When a field is conditionally required, the client can no longer assume that all required fields will have a value. It may be the case that the condition of requirement was not met when the record was added, but now it is. For example, consider these field definitions:
<field name="yearsAtCurrentAddress" type="integer" /> <field name="previousAddress" type="text" > <validator type="required" errorMessage="Previous address is required if you have been at your current address less than three years"> <applyWhen operator="and"> <criteria> <criterion fieldName="yearsAtCurrentAddress" operator="lessThan" value="3" /> </criteria> </applyWhen> </validator> </field>Imagine a record for this DataSource is added where the user has entered a value of "3" for "yearsAtCurrentAddress", and no previous address. Later, the value of that field is changed to "2". If this is done using a form that is also showing the "previousAddress" field, we will know that "previousAddress" has not been provided, so we can fail the validation and the user will get a helpful error message explaining what the problem is.
However, if the form does not also show the "previousAddress" field, we may choose to use an
OperationBinding
that uses outputs
to trim the
record down to just the fields the form does contain, in the interests of avoiding
information leakage. Or perhaps that value is automatically culled from the record before
the client sees it by the application of a declarative security rule
.
Whatever the reason, if the client does not have the complete record, it is not possible
for the client to sensibly apply this validation. And because the client has no way of
knowing if a value is missing because it is genuinely null, or because it has been trimmed
away by the server, we must treat any null value with suspicion (unless it has a matching
FormItem - the presence of the FormItem means that the user can edit the value, so it
would make no sense to pair it with a trimmed record that excludes that field value).
When this happens, we mark the validation as having passed on the client, but in need of
running on the server. The server validation makes use of the "storedRecord" facility
(look for the description of $storedRecord in the
Velocity support overview
) to overlay the changed record on
top of the existing record as it currently exists in the database. This gives the validator
the complete record including both changed and unchanged values, so it is able to carry
out the required check in a meaningful way. However, you should be aware that the
combination of conditional "required" validators and DynamicForms that edit partial
records can result in a validation that cannot run on the client and must do both a server
roundtrip and a database fetch.
Validator.getApplyWhen()
public DataSourceField setRequiredMessage(java.lang.String requiredMessage)
required
is not filled in by the user. Note that this setting wins over DataSource.requiredMessage
if both are set.
requiredMessage
- New requiredMessage value. Default value is nullDataSourceField
instance, for chaining setter callsFormTitles overview and related methods
public java.lang.String getRequiredMessage()
required
is not filled in by the user. Note that this setting wins over DataSource.requiredMessage
if both are set.
FormTitles overview and related methods
public DataSourceField setRootValue(java.lang.Object rootValue)
Note that the rootValue may be overridden on a specific ResultTree instance by setting ResultTree.rootNode
, or if the ResultTree is auto-generated by
a TreeGrid
, by setting TreeGrid.treeRootValue
. This allows a component to navigate
a subtree of the hierarchical data from this dataSource starting at a particular node.
rootValue
- New rootValue value. Default value is nullDataSourceField
instance, for chaining setter callsDataSourceRelations overview and related methods
public java.lang.Object getRootValue()
Note that the rootValue may be overridden on a specific ResultTree instance by setting ResultTree.rootNode
, or if the ResultTree is auto-generated by
a TreeGrid
, by setting TreeGrid.treeRootValue
. This allows a component to navigate
a subtree of the hierarchical data from this dataSource starting at a particular node.
DataSourceRelations overview and related methods
public DataSourceField setSequenceName(java.lang.String sequenceName)
serverType:"sql"
with a field of
type
"sequence", the name of the SQL sequence that should be used when inserting new records into
this table.
Note that this is never required for SQL tables that are generated from Smart GWT DataSources (a default sequence name of tableName + "_" + columnName is chosen, but see the notes below regarding this), and is never required for databases where inserting null into a sequence column is sufficient (MySQL, SQL Server, DB2 and others).
You would only need to set sequenceName if you are integrating with a pre-existing table stored in a database where the sequence must be named for insertion to work (Oracle, Postgres, Firebird) OR you are trying to use the same sequence across multiple DataSources.
Note: If you specify the sql.{database type}.sequence.name.prefix
and/or
sql.{database type}.sequence.name.suffix
properties in your
server.properties
file,the generated sequence name will include the
prefix and/or
suffix. For example, with a prefix of "order_system_" and a suffix of "_seq", the sequence
generated for column "orderNumber" on table "orders" would be:
order_system_orders_orderNumber_seq
sequenceName
- New sequenceName value. Default value is nullDataSourceField
instance, for chaining setter callsSqlDataSource overview and related methods
public java.lang.String getSequenceName()
serverType:"sql"
with a field of
type
"sequence", the name of the SQL sequence that should be used when inserting new records into
this table.
Note that this is never required for SQL tables that are generated from Smart GWT DataSources (a default sequence name of tableName + "_" + columnName is chosen, but see the notes below regarding this), and is never required for databases where inserting null into a sequence column is sufficient (MySQL, SQL Server, DB2 and others).
You would only need to set sequenceName if you are integrating with a pre-existing table stored in a database where the sequence must be named for insertion to work (Oracle, Postgres, Firebird) OR you are trying to use the same sequence across multiple DataSources.
Note: If you specify the sql.{database type}.sequence.name.prefix
and/or
sql.{database type}.sequence.name.suffix
properties in your
server.properties
file,the generated sequence name will include the
prefix and/or
suffix. For example, with a prefix of "order_system_" and a suffix of "_seq", the sequence
generated for column "orderNumber" on table "orders" would be:
order_system_orders_orderNumber_seq
SqlDataSource overview and related methods
public DataSourceField setShowFileInline(java.lang.Boolean showFileInline)
showFileInline
- New showFileInline value. Default value is nullDataSourceField
instance, for chaining setter callspublic java.lang.Boolean getShowFileInline()
public DataSourceField setSortByField(java.lang.String sortByField)
This can be used to establish a sort order for a field that is not the normal sorting order indicated by
the field value, typically by having the sortByField
as a hidden field
.
If using SQLDataSource, consider using a customSelectExpression
as an efficient way to
populate the sortByField
with the results of a SQL expression.
sortByField
- New sortByField value. Default value is nullDataSourceField
instance, for chaining setter callspublic java.lang.String getSortByField()
This can be used to establish a sort order for a field that is not the normal sorting order indicated by
the field value, typically by having the sortByField
as a hidden field
.
If using SQLDataSource, consider using a customSelectExpression
as an efficient way to
populate the sortByField
with the results of a SQL expression.
public DataSourceField setStringInBrowser(java.lang.Boolean stringInBrowser)
JavaScript has a single "Number" type which internally stores numbers in a format equivalent to Java's "Double" - double-precision floating point. This means it cannot represent the full range of Java's Long type: Java Longs can represent integral values between -2^63 to 2^63-1, whereas JavaScript Number can only represent exact integer values between -2^53 and 2^53. Similarly, JavaScript's Number type cannot represent Java's unlimited-size BigInteger or unlimited-precision BigDecimal objects at all.
The stringInBrowser
setting can be used to deliver
numeric values as Strings to the browser. This is intended to allow read-only display and successful round-tripping of
the numeric value, however, it will not cause number-oriented features such as SpinnerItem
, Slider
, ListGrid summaries
or range-checking validators
or criteria
to actually work.
If stringInBrowser
is not set, the default behavior is configured by the
server.properties
setting datasource.defaultStringInBrowser
. If this flag is false, numeric
values are delivered to the client as numbers, even where this will lead to a loss of precision. If the flag
is true (which is the the default), the behavior is to prevent range overflow for numeric values:
DMI methods
are called. This default set of behaviors is intended to automatically deal with cases like numeric primaryKey
or foreignKey
values that are never used as numbers, but happen to
use the full Java Long range. To disable the above behaviors, set stringInBrowser="false"
.
If
stringInBrowser
is explicitly set to true:
operators
that check if values are in a particular range will always
pass canFilter:false
were set, to avoid showing non-functional search interfaces to the user. Set canFilter="true"
to
avoid this effect This setting is recommended for presenting out-of-range issues or precision loss on
fields that represent actual quantities (as opposed to primaryKey or foreignKey fields, which really represent IDs). To
ensure unlimited-precision BigDecimal values are preserved, you should also set javaClass
.
Note that responses delivered as JSON or
XML, such as responses from the RESTHandler servlet
, are not affected.
This setting applies only to responses delivered to a web browser.
The entirety of stringInBrowser processing can be
completely disabled by setting server.properties
flag datasource.disableStringInBrowser
to
true. This will cause all numeric values to be delivered as numbers without even attempting to detect if this will lead
to a loss of precision. This setting overrides both the stringInBrowser
field setting and the
datasource.defaultStringInBrowser server.properties
flag.
stringInBrowser
and
client-side DataSources
For DataSources that are not based on the Smart GWT Server, the client-side behaviors described above (such as leaving user input in string form if precision would be lost) are active by default.
In
addition, if dataSource.dataFormat:"xml"
is used, values that
would lose precision remain as strings. For JSON, if behavior similar to stringInBrowser
is desired, your
server response must send the values as JSON strings rather than JSON numeric literals.
You can use defaultStringInBrowser
to disable these behaviors.
NOTE: don't use this setting if you are using the Smart GWT Server, use the server.properties approach described
above instead.
stringInBrowser
- New stringInBrowser value. Default value is nullDataSourceField
instance, for chaining setter callspublic java.lang.Boolean getStringInBrowser()
JavaScript has a single "Number" type which internally stores numbers in a format equivalent to Java's "Double" - double-precision floating point. This means it cannot represent the full range of Java's Long type: Java Longs can represent integral values between -2^63 to 2^63-1, whereas JavaScript Number can only represent exact integer values between -2^53 and 2^53. Similarly, JavaScript's Number type cannot represent Java's unlimited-size BigInteger or unlimited-precision BigDecimal objects at all.
The stringInBrowser
setting can be used to deliver
numeric values as Strings to the browser. This is intended to allow read-only display and successful round-tripping of
the numeric value, however, it will not cause number-oriented features such as SpinnerItem
, Slider
, ListGrid summaries
or range-checking validators
or criteria
to actually work.
If stringInBrowser
is not set, the default behavior is configured by the
server.properties
setting datasource.defaultStringInBrowser
. If this flag is false, numeric
values are delivered to the client as numbers, even where this will lead to a loss of precision. If the flag
is true (which is the the default), the behavior is to prevent range overflow for numeric values:
DMI methods
are called. This default set of behaviors is intended to automatically deal with cases like numeric primaryKey
or foreignKey
values that are never used as numbers, but happen to
use the full Java Long range. To disable the above behaviors, set stringInBrowser="false"
.
If
stringInBrowser
is explicitly set to true:
operators
that check if values are in a particular range will always
pass canFilter:false
were set, to avoid showing non-functional search interfaces to the user. Set canFilter="true"
to
avoid this effect This setting is recommended for presenting out-of-range issues or precision loss on
fields that represent actual quantities (as opposed to primaryKey or foreignKey fields, which really represent IDs). To
ensure unlimited-precision BigDecimal values are preserved, you should also set javaClass
.
Note that responses delivered as JSON or
XML, such as responses from the RESTHandler servlet
, are not affected.
This setting applies only to responses delivered to a web browser.
The entirety of stringInBrowser processing can be
completely disabled by setting server.properties
flag datasource.disableStringInBrowser
to
true. This will cause all numeric values to be delivered as numbers without even attempting to detect if this will lead
to a loss of precision. This setting overrides both the stringInBrowser
field setting and the
datasource.defaultStringInBrowser server.properties
flag.
stringInBrowser
and
client-side DataSources
For DataSources that are not based on the Smart GWT Server, the client-side behaviors described above (such as leaving user input in string form if precision would be lost) are active by default.
In
addition, if dataSource.dataFormat:"xml"
is used, values that
would lose precision remain as strings. For JSON, if behavior similar to stringInBrowser
is desired, your
server response must send the values as JSON strings rather than JSON numeric literals.
You can use defaultStringInBrowser
to disable these behaviors.
NOTE: don't use this setting if you are using the Smart GWT Server, use the server.properties approach described
above instead.
public DataSourceField setSummaryValueTitle(java.lang.String summaryValueTitle)
Summary of type "title"
for this field. If
unspecified title
summaries will show the title
for the field.summaryValueTitle
- New summaryValueTitle value. Default value is nullDataSourceField
instance, for chaining setter callspublic java.lang.String getSummaryValueTitle()
Summary of type "title"
for this field. If
unspecified title
summaries will show the title
for the field.public DataSourceField setTimeFormatter(TimeDisplayFormat timeFormatter)
ListGrid
or DynamicForm
, any dates displayed in this field will be formatted as times using the
appropriate format. This is most commonly only applied to fields specified as type "time"
though if no
explicit FormItem.dateFormatter
is specified
it will be respected for other fields as well.
See ListGridField.timeFormatter
and FormItem.timeFormatter
for more information.
Note : This is an advanced setting
timeFormatter
- New timeFormatter value. Default value is nullDataSourceField
instance, for chaining setter callsAppearance overview and related methods
public TimeDisplayFormat getTimeFormatter()
ListGrid
or DynamicForm
, any dates displayed in this field will be formatted as times using the
appropriate format. This is most commonly only applied to fields specified as type "time"
though if no
explicit FormItem.dateFormatter
is specified
it will be respected for other fields as well.
See ListGridField.timeFormatter
and FormItem.timeFormatter
for more information.
Appearance overview and related methods
public DataSourceField setTitle(java.lang.String title)
This will be picked up by DataBound components and other views over this DataSource.
Note this property frequently does not need to be set since DataSource.autoDeriveTitles
(on by default) usually picks an
appropriate user-visible title if you have a reasonable naming convention for your field names.
Note that if this
field is being displayed in a ListGrid
bound to this dataSource, the ListGridField.headerTitle
attribute may be used to
specify a different string for display in the listGrid column header.
title
- New title value. Default value is nullDataSourceField
instance, for chaining setter callsComponentBinding overview and related methods
public java.lang.String getTitle()
This will be picked up by DataBound components and other views over this DataSource.
Note this property frequently does not need to be set since DataSource.autoDeriveTitles
(on by default) usually picks an
appropriate user-visible title if you have a reasonable naming convention for your field names.
Note that if this
field is being displayed in a ListGrid
bound to this dataSource, the ListGridField.headerTitle
attribute may be used to
specify a different string for display in the listGrid column header.
ComponentBinding overview and related methods
public DataSourceField setType(FieldType type)
Field type may imply automatic validators (for example, an integer field cannot accept the value "foo"). Field type also affects the default behaviors of DataBound components, for example, if a field is declared as type "date", components that edit that field will automatically choose a date-editing interface with pop-up date picker.
type
- New type value. Default value is nullDataSourceField
instance, for chaining setter callsBasics overview and related methods
public DataSourceField setUploadFieldName(java.lang.String uploadFieldName)
BatchUploader
to map a field in an upload file to this dataSourceField.
This is only necessary if the dataSourceField's name and title differ from the name of the field in the upload file
(Smart GWT will automatically map upload fields using the dataSourceField's title, if possible, if it does not get a
direct match on field name).uploadFieldName
- New uploadFieldName value. Default value is nullDataSourceField
instance, for chaining setter callspublic java.lang.String getUploadFieldName()
BatchUploader
to map a field in an upload file to this dataSourceField.
This is only necessary if the dataSourceField's name and title differ from the name of the field in the upload file
(Smart GWT will automatically map upload fields using the dataSourceField's title, if possible, if it does not get a
direct match on field name).public DataSourceField setUseLocalDisplayFieldValue(java.lang.Boolean useLocalDisplayFieldValue)
FormItem.useLocalDisplayFieldValue
attribute may be specified within a dataSource configuration. This property
governs whether, when displaying a record in an editor component, the displayField
value for this field
should be picked up directly from the record value (as opposed to being retrieved via an explicit fetch operation
against the FormItem.optionDataSource
). See
FormItem.useLocalDisplayFieldValue
for further details.
If not explicitly set, dataSources backed by the Smart GWT server
will set this property to true automatically for fields
where the specified displayField
values are retrieved
from another dataSource using the includeFrom
feature.
useLocalDisplayFieldValue
- New useLocalDisplayFieldValue value. Default value is nullDataSourceField
instance, for chaining setter callspublic java.lang.Boolean getUseLocalDisplayFieldValue()
FormItem.useLocalDisplayFieldValue
attribute may be specified within a dataSource configuration. This property
governs whether, when displaying a record in an editor component, the displayField
value for this field
should be picked up directly from the record value (as opposed to being retrieved via an explicit fetch operation
against the FormItem.optionDataSource
). See
FormItem.useLocalDisplayFieldValue
for further details.
If not explicitly set, dataSources backed by the Smart GWT server
will set this property to true automatically for fields
where the specified displayField
values are retrieved
from another dataSource using the includeFrom
feature.
public DataSourceField setValidators(Validator... validators)
Validators are applied whenever there is an attempt to save changes to a field.
For the available set of built-in validators, and how to define a custom validator, see the Validator
class.
validators
- New validators value. Default value is nullDataSourceField
instance, for chaining setter callsValidator
,
Validation overview and related methods
public Validator[] getValidators()
Validators are applied whenever there is an attempt to save changes to a field.
For the available set of built-in validators, and how to define a custom validator, see the Validator
class.
Validator
,
Validation overview and related methods
public DataSourceField setValidOperators(OperatorId... validOperators)
If not specified, all operators that are valid for the field type are allowed.
validOperators
- New validOperators value. Default value is nullDataSourceField
instance, for chaining setter callsAdvancedFilter overview and related methods
public OperatorId[] getValidOperators()
If not specified, all operators that are valid for the field type are allowed.
AdvancedFilter overview and related methods
public DataSourceField setValueMap(java.util.Map valueMap)
com.smartgwt.client.types.ValueMap
is a set of legal values for a field.
The valueMap can be specified as either an Array of legal values, or as an
Object
where each property maps a stored value to a user-displayable value.
To enforce that a field should be constrained to only the values in the valueMap, either
declare field.type
as "enum", or use a
ValidatorType
of "isOneOf" with explicitly listed values. Otherwise,
although a normal SelectItem
control will only allow values from the
valueMap to be
entered, other controls such as a ComboBox
will allow other
values
to be entered.
In XML, a valueMap that specifies only a list of legal values is specified as follows:
<valueMap> <value>Pens & Pencils</value> <value>Stationery</value> <value>Computer Products</value> <value>Furniture</value> <value>Misc</value> </valueMap>A ValueMap that specifies stored values mapped to user-visible values is specified as follows:
<valueMap> <value ID="1">Pens & Pencils</value> <value ID="2">Stationery</value> <value ID="3">Computer Products</value> <value ID="4">Furniture</value> <value ID="5">Misc</value> </valueMap>
valueMap
- New valueMap value. Default value is nullDataSourceField
instance, for chaining setter callspublic java.util.Map getValueMap()
com.smartgwt.client.types.ValueMap
is a set of legal values for a field.
The valueMap can be specified as either an Array of legal values, or as an
Object
where each property maps a stored value to a user-displayable value.
To enforce that a field should be constrained to only the values in the valueMap, either
declare field.type
as "enum", or use a
ValidatorType
of "isOneOf" with explicitly listed values. Otherwise,
although a normal SelectItem
control will only allow values from the
valueMap to be
entered, other controls such as a ComboBox
will allow other
values
to be entered.
In XML, a valueMap that specifies only a list of legal values is specified as follows:
<valueMap> <value>Pens & Pencils</value> <value>Stationery</value> <value>Computer Products</value> <value>Furniture</value> <value>Misc</value> </valueMap>A ValueMap that specifies stored values mapped to user-visible values is specified as follows:
<valueMap> <value ID="1">Pens & Pencils</value> <value ID="2">Stationery</value> <value ID="3">Computer Products</value> <value ID="4">Furniture</value> <value ID="5">Misc</value> </valueMap>
public DataSourceField setValueXPath(java.lang.String valueXPath)
This XPath expression will be evaluated in the scope of the record objects selected by
the DataSource.recordXPath
. For XML data
(dataFormat:"xml"
) this means a call to
XMLTools.selectString()
passing the selected XML element. For
JSON data
(dataFormat:"json"
), this means a call to
XMLTools.selectObjects()
passing the selected JSON object.
In the absence of a valueXPath
, for JSON data the value for the field will
be the value of the same-named property in the record object selected by
recordXPath
.
For XML data, the value will be the attribute or subelement named after the field name. For example, for a field "author" on a record element <book>, the following structures require no valueXPath:
<book author="Mark Jones"/> <book> <author>Mark Jones</author> </book>
If valueXPath
is not required for your field because of the default handling
described above, don't specify it, as it's slightly slower.
To learn about XPath, try the following search: http://www.google.com/search?q=xpath+tutorial
Using valueXPath with the Smart GWT server
If you're using the Smart GWT server to return data via the DSResponse object (or
indirectly doing so using DataSource DMI), the valueXPath you specify on the DataSource
fields will be applied to the data you return via the
JXPath library.
See also the server side Java APIs DataSource.setProperties()
and
DSResponse.setData()
.
If you are returning Java Beans as your DSResponse data, normally each dataSource field
receives the value of the same-named Java Bean property, that is, a field "zipCode" is
populated by looking for "getZipCode()" on the objects passed as DSResponse data. You can
use valueXPath
to retrieve properties from subobjects, so long as a chain of
getter methods exists that corresponds to the valueXPath. For example, a valueXPath of
"address/zipCode" expects to call "getAddress()" on the bean(s) passed to
DSResponse.setData(), followed by "getZipCode()" on whatever object "getAddress()" returns.
When you are saving data, the inbound DSRequest values, available as a Java Map, will use just dataSource field names as Map keys, not the valueXPath used to derive them. However, to achieve bidirectional valueXPath binding, you can use the server-side method dataSource.setProperties() to use the valueXPath when setting properties on your server object model. When applied as a setter, an XPath like "address/zipCode" attempts "getAddress()" followed by "setZipCode()" on the returned object. JXPath also has some ability to auto-create intervening objects if they are missing, such as auto-creating an "address" subobject when applying "address/zipCode" as a valueXPath.
See the JXPath library documentation for complete details, including other types of server object models supported, such as server-side XML.
valueXPath
- New valueXPath value. Default value is nullDataSourceField
instance, for chaining setter callsXPathExpression
,
ClientDataIntegration overview and related methods
,
XPath Binding Examplepublic java.lang.String getValueXPath()
This XPath expression will be evaluated in the scope of the record objects selected by
the DataSource.recordXPath
. For XML data
(dataFormat:"xml"
) this means a call to
XMLTools.selectString()
passing the selected XML element. For
JSON data
(dataFormat:"json"
), this means a call to
XMLTools.selectObjects()
passing the selected JSON object.
In the absence of a valueXPath
, for JSON data the value for the field will
be the value of the same-named property in the record object selected by
recordXPath
.
For XML data, the value will be the attribute or subelement named after the field name. For example, for a field "author" on a record element <book>, the following structures require no valueXPath:
<book author="Mark Jones"/> <book> <author>Mark Jones</author> </book>
If valueXPath
is not required for your field because of the default handling
described above, don't specify it, as it's slightly slower.
To learn about XPath, try the following search: http://www.google.com/search?q=xpath+tutorial
Using valueXPath with the Smart GWT server
If you're using the Smart GWT server to return data via the DSResponse object (or
indirectly doing so using DataSource DMI), the valueXPath you specify on the DataSource
fields will be applied to the data you return via the
JXPath library.
See also the server side Java APIs DataSource.setProperties()
and
DSResponse.setData()
.
If you are returning Java Beans as your DSResponse data, normally each dataSource field
receives the value of the same-named Java Bean property, that is, a field "zipCode" is
populated by looking for "getZipCode()" on the objects passed as DSResponse data. You can
use valueXPath
to retrieve properties from subobjects, so long as a chain of
getter methods exists that corresponds to the valueXPath. For example, a valueXPath of
"address/zipCode" expects to call "getAddress()" on the bean(s) passed to
DSResponse.setData(), followed by "getZipCode()" on whatever object "getAddress()" returns.
When you are saving data, the inbound DSRequest values, available as a Java Map, will use just dataSource field names as Map keys, not the valueXPath used to derive them. However, to achieve bidirectional valueXPath binding, you can use the server-side method dataSource.setProperties() to use the valueXPath when setting properties on your server object model. When applied as a setter, an XPath like "address/zipCode" attempts "getAddress()" followed by "setZipCode()" on the returned object. JXPath also has some ability to auto-create intervening objects if they are missing, such as auto-creating an "address" subobject when applying "address/zipCode" as a valueXPath.
See the JXPath library documentation for complete details, including other types of server object models supported, such as server-side XML.
XPathExpression
,
ClientDataIntegration overview and related methods
,
XPath Binding Examplepublic DataSourceField setXmlAttribute(java.lang.Boolean xmlAttribute)
DataSource.xmlSerialize()
should serialize this
value as an XML attribute. Note this does not need to be declared in order for DataSource records to be derived from XML data: a field will be populated with either an attribute or subelement with matching name.
xmlAttribute
- New xmlAttribute value. Default value is nullDataSourceField
instance, for chaining setter callsComponentSchema overview and related methods
public java.lang.Boolean getXmlAttribute()
DataSource.xmlSerialize()
should serialize this
value as an XML attribute. Note this does not need to be declared in order for DataSource records to be derived from XML data: a field will be populated with either an attribute or subelement with matching name.
ComponentSchema overview and related methods
public void setPluralTitle(java.lang.String pluralTitle)
pluralTitle
- the plural titlepublic java.lang.String getPluralTitle()
public void setType(SimpleType type)
type
- the SimpleTypepublic void setValueMap(java.lang.String... valueMap)
The valueMap can be specified as either an Array of legal values, or as an Object where each property maps a stored value to a user-displayable value.
To
enforce that a field should be constrained to only the values in the valueMap, either
declare field.type
as "enum", or use a
ValidatorType
of "inSet" with explicitly listed values. Otherwise,
although a normal
SelectItem
control will only allow values from the valueMap to be
entered, other controls such as a ComboBox
will allow other
values
to be entered.
In XML, a valueMap that specifies only a list of legal values is specified as follows:
<valueMap> <value>Pens & Pencils</value> <value>Stationery</value> <value>Computer Products</value> <value>Furniture</value> <value>Misc</value> </valueMap>A ValueMap that specifies stored values mapped to user-visible values is specified as follows:
<valueMap> <value ID="1">Pens & Pencils</value> <value ID="2">Stationery</value> <value ID="3">Computer Products</value> <value ID="4">Furniture</value> <value ID="5">Misc</value> </valueMap>
valueMap
- valueMap Default value is nullpublic void setEditorProperties(FormItem editorProperties)
FormItem
properties to be used whenever this
field is edited (whether in a grid, form, or other component).
If unset, a FormItem will be automatically chosen based on the type of the field.
Note: The FormItem passed to setEditorProperties() is used as a "template" to create a FormItem whenever
a DataBoundComponent
needs to show an interface for editing this
field. This means you need to follow special rules:
new MyCustomItem(item.getJsObj());
(complete code sample below).class MyCustomItem extends TextItem { MyCustomItem (JavaScriptObject config) { } MyCustomItem(String name) { setInitHandler(new FormItemInitHandler() { public void onInit(FormItem item) { // correct new MyCustomItem(item.getJsObj()).customMethod(); // incorrect, will throw an error // ((MyCustomItem)item).customMethod(); } } } void customMethod() { ... } } ... myDataSourceField.setEditorProperties(new MyCustomItem("field1"));
As an alternative, you can use setEditorType(String)
or
setEditorType(Class)
to avoid these limitations, if you register
the FormItem subclass with the reflection mechanism
.
editorProperties
- FormItem with default properties to be applied when editingpublic void setEditorType(FormItem editorType)
setEditorProperties(FormItem)
. You can also consider using
setEditorType(Class)
or setEditorType(String)
instead.setEditorProperties(FormItem)
.editorType
- FormItem with default properties to be applied when editingpublic void setEditorType(java.lang.String editorType)
FormItem
class to be used whenever this field is edited
(whether in a grid, form, or other component).
If unset, a FormItem will be automatically chosen based on the type of the field.
By using the reflection mechanism
,
this method avoids the limitations described in setEditorProperties(FormItem)
.
editorType
- the fully-qualified class name of a FormItem
subclass, which must have been registered with the
reflection mechanism
.java.lang.IllegalArgumentException
- if the editorType class has not beeen registered for use with the
reflection mechanism
,
or if it does not inherit from
FormItem
.public void setEditorType(java.lang.Class<? extends FormItem> editorType)
FormItem
class to be used whenever this field is edited
(whether in a grid, form, or other component).
If unset, a FormItem will be automatically chosen based on the type of the field.
By using the reflection mechanism
,
this method avoids the limitations described in setEditorProperties(FormItem)
.
editorType
- a FormItem
subclass, which must have been registered with the
reflection mechanism
.java.lang.IllegalArgumentException
- if the editorType class has not beeen registered for use with the
reflection mechanism
,
or if it does not inherit from
FormItem
.public void setReadOnlyEditorType(FormItem editorType)
setReadOnlyEditorProperties(FormItem)
. You can
also consider using setReadOnlyEditorType(Class)
or
setReadOnlyEditorType(String)
instead.setReadOnlyEditorProperties(FormItem)
.editorType
- FormItem with properties to set when editing read-only values.public void setReadOnlyEditorProperties(FormItem editorProperties)
canEdit false
and displayed in an editor component such as a DynamicForm.
This property may also be specified at the type level by specifying
SimpleType.setReadOnlyEditorType(FormItem)
.
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). This means you need to follow special rules indicated
for setEditorProperties(FormItem)
.
As an alternative, you can use setReadOnlyEditorType(String)
or
setReadOnlyEditorType(Class)
to avoid these limitations, if you register
the FormItem subclass with the reflection mechanism
.
editorProperties
- FormItem with properties to set when editing read-only values.public void setReadOnlyEditorType(java.lang.String editorType)
canEdit false
and displayed in an editor component
such as a DynamicForm.
By using the reflection mechanism
,
this method avoids the limitations described in setReadOnlyEditorProperties(FormItem)
.
editorType
- a FormItem
subclass, which must have been registered with the
reflection mechanism
.java.lang.IllegalArgumentException
- if the editorType class has not beeen registered for use with the
reflection mechanism
,
or if it does not inherit from
FormItem
.public void setReadOnlyEditorType(java.lang.Class<? extends FormItem> editorType)
FormItem
class to be used if this field is marked as
canEdit false
and displayed in an editor component such as a DynamicForm.
By using the reflection mechanism
,
this method avoids the limitations described in setReadOnlyEditorProperties(FormItem)
.
editorType
- a FormItem
subclass, which must have been registered with the
reflection mechanism
.java.lang.IllegalArgumentException
- if the editorType class has not beeen registered for use with the
reflection mechanism
,
or if it does not inherit from
FormItem
.public void setFilterEditorProperties(FormItem filterEditorProperties)
FormItem
properties to be used whenever this
field if it appears in a ListGrid
filter row,
and canFilter
is not false.
Note: If this is not specified, the formItem type may be derived from the
filterEditorType
property, or from the field's type
.
Note: The FormItem passed to setFilterEditorProperties()
is used as a
"template" to create a FormItem. See rules in
setEditorProperties(com.smartgwt.client.widgets.form.fields.FormItem)
.
filterEditorProperties
- FormItem with default properties to be appliedpublic void setFilterEditorType(java.lang.String filterEditorType)
FormItem
class to be used whenever this field appears
in a ListGrid
filter row or
SearchForm
.
If unset, a FormItem will be automatically chosen based on the type of the field.
By using the reflection mechanism
,
this method avoids the limitations described in setFilterEditorProperties(FormItem)
.
filterEditorType
- the fully-qualified class name of a
FormItem
subclass, which must have
been registered with the reflection mechanism
.java.lang.IllegalArgumentException
- if the filterEditorType class has not beeen registered
for use with the reflection mechanism
,
or if it does not inherit from FormItem
.public void setFilterEditorType(java.lang.Class<? extends FormItem> filterEditorType)
FormItem
class to be used whenever this field appears
in a ListGrid
filter row or
SearchForm
.
If unset, a FormItem will be automatically chosen based on the type of the field.
By using the reflection mechanism
,
this method avoids the limitations described in setFilterEditorProperties(FormItem)
.
editorType
- a FormItem
subclass, which must have been registered with the
reflection mechanism
.java.lang.IllegalArgumentException
- if the filterEditorType class has not beeen registered
for use with the reflection mechanism
,
or if it does not inherit from FormItem
.public void setRootValue(java.lang.String rootValue)
rootValue
- rootValue Default value is nullpublic void setRootValue(java.lang.Integer rootValue)
rootValue
- rootValue Default value is nullpublic void setRootValue(java.lang.Float rootValue)
rootValue
- rootValue Default value is nullpublic void setFieldValueExtractor(FieldValueExtractor extractor)
This is an advanced API for use when a valueXPath
setting is insufficient to derive a field's value, yet an implementation of DataSource.transformResponse(com.smartgwt.client.data.DSResponse, com.smartgwt.client.data.DSRequest, java.lang.Object)
is overkill.
extractor
- the field value extractorpublic void setType(DataSource dataSource)
dataSource
- the data sourcepublic void setTypeAsDataSource(DataSource dataSource)
dataSource
- the data sourcepublic DataSource getTypeAsDataSource()
public void setSummaryFunction(SummaryFunctionType summaryFunction)
showGridSummary
or showGroupSummary
is true, this attribute can be used to
specify an explicit SummaryFunction
for calculating the summary value to display.summaryFunction
- summaryFunction Default value is nullpublic void setSummaryFunction(java.lang.String summaryFunction)
showGridSummary
or showGroupSummary
is true, this attribute can be used to
specify an summary function registered via com.smartgwt.client.data.SimpleType#registerSummaryFunction()
for calculating the summary value to display.summaryFunction
- summaryFunction Default value is nullpublic SummaryFunctionType getSummaryFunction()
showGridSummary
or showGroupSummary
is true, this attribute can be used to
specify an explicit SummaryFunction
for calculating the summary value to display.public void setSummaryFunction(SummaryFunction summaryFunction)
showGridSummary
or showGroupSummary
is true, this attribute can be used to
specify an explicit SummaryFunction
for calculating the summary value to display.summaryFunction
- summaryFunction Default value is nullpublic void setImageHeight(java.lang.Integer imageHeight)
ViewFileItem
as an editor.imageHeight
- imageHeight Default value is nullpublic java.lang.Integer getImageHeight()
ViewFileItem
as an editor.public void setImageHeight(java.lang.String imageHeight)
ViewFileItem
as an editor.imageHeight
- imageHeight Default value is nullpublic java.lang.String getImageHeightAsString()
ViewFileItem
as an editor.public void setImageSize(java.lang.Integer imageSize)
ViewFileItem
as an editor.imageSize
- imageSize Default value is nullpublic java.lang.Integer getImageSize()
ViewFileItem
as an editor.public void setImageSize(java.lang.String imageSize)
ViewFileItem
as an editor.imageSize
- imageSize Default value is nullpublic java.lang.String getImageSizeAsString()
ViewFileItem
as an editor.public void setImageWidth(java.lang.Integer imageWidth)
ViewFileItem
as an editor.imageWidth
- imageWidth Default value is nullpublic java.lang.Integer getImageWidth()
ViewFileItem
as an editor.public void setImageWidth(java.lang.String imageWidth)
ViewFileItem
as an editor.imageWidth
- imageWidth Default value is nullpublic java.lang.String getImageWidthAsString()
ViewFileItem
as an editor.public void setPrompt(java.lang.String prompt)
prompt
for the header).prompt
- prompt Default value is nullpublic java.lang.String getPrompt()
prompt
for the header).public void setCanEdit(java.lang.Boolean canEdit)
Set to false
to draw
this field read-only.
This attribute may not effect all dataBoundComponents - the canEditFieldAttribute
may be set at the
component level to look for a different attribute on the dataSourceField, and components allow developers to explicitly
override this default (see canEdit
. canEdit
for example).
Note that this setting only
prevents the user from modifying the field's value through the UI; the value can still be modified programmatically,
and it will still be saved in the normal way. If you wish to prevent a field from being saved, use canSave
:false instead (or in addition).
canEdit
- canEdit Default value is nullsetCanFilter(java.lang.Boolean)
,
setCanSave(java.lang.Boolean)
,
ComponentBinding overview and related methods
public java.lang.Boolean getCanEdit()
Set to false
to draw
this field read-only.
This attribute may not effect all dataBoundComponents - the canEditFieldAttribute
may be set at the
component level to look for a different attribute on the dataSourceField, and components allow developers to explicitly
override this default (see canEdit
. canEdit
for example).
Note that this setting only
prevents the user from modifying the field's value through the UI; the value can still be modified programmatically,
and it will still be saved in the normal way. If you wish to prevent a field from being saved, use canSave
:false instead (or in addition).
getCanFilter()
,
getCanSave()
,
ComponentBinding overview and related methods
public SimpleType getTypeAsSimpleType()
public FieldType getType()
Field type may imply automatic validators (for example, an integer field cannot accept the value "foo"). Field type also affects the default behaviors of DataBound components, for example, if a field is declared as type "date", components that edit that field will automatically choose a date-editing interface with pop-up date picker. If the type of this field is a DataSource type, the returned object will be null.
Basics overview and related methods