|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.smartgwt.client.core.JsObject
com.smartgwt.client.core.DataClass
com.smartgwt.client.data.OperationBinding
public class OperationBinding
An operationBinding tells a DataSource how to execute one of the basic DS operations: fetch, add, update, remove. See
operationBindings
.
Field Summary |
---|
Fields inherited from class com.smartgwt.client.core.JsObject |
---|
jsObj |
Constructor Summary | |
---|---|
OperationBinding()
|
|
OperationBinding(DSOperationType operationType,
String dataURL)
|
|
OperationBinding(JavaScriptObject jsObj)
|
Method Summary | |
---|---|
Boolean |
getAllowMultiUpdate()
Ordinarily, "update" and "remove" operations are only allowed for DataSource s that have
a 'primaryKey' , and all primary key values are present in
the request. |
String |
getCallbackParam()
Applies only to dataFormat: "json". |
DSDataFormat |
getDataFormat()
Format for response data for this operation. |
DSProtocol |
getDataProtocol()
Controls the format in which inputs are sent to the dataURL. |
RPCTransport |
getDataTransport()
Transport to use for this operation. |
String |
getDataURL()
URL to contact to fulfill DSRequests for this operationBinding. |
ExportFormat |
getExportAs()
The format in which the data should be exported. |
String[] |
getExportFields()
The list of field-names to export. |
String |
getExportFilename()
The name of the file to save the exported data into. |
Boolean |
getExportResults()
When set, causes the results of the DataSource Operation to be exported to a file, whose name and format are indicated by exportFilename and
exportAs respectively. |
Boolean |
getInvalidateCache()
If set, every invocation of this operationBinding will invalidate the local cache, forcing a server visit to refresh the data. |
String |
getLineBreakStyle()
The style of line-breaks to use in the exported output. |
String |
getOperationId()
Optional operationId if this DataSource supports two or more variants of one of the basic DataSource operations, for instance, a "fetch" that uses full text search and a "fetch" that accepts per-field search criteria. |
DSOperationType |
getOperationType()
Which operationType this operationBinding is for. |
static OperationBinding |
getOrCreateRef(JavaScriptObject jsObj)
|
String |
getOutputs()
Specifies, for this operationBinding only, the list of field names that should be returned to the client. |
Boolean |
getPreventHTTPCaching()
Configures preventHTTPCaching on a per-operationType
basis. |
String |
getRecordName()
For an XML DataSource, tagName of the elements to be used as records. |
String |
getRecordXPath()
For an XML or JSON DataSource, XPath expression used to retrieve the objects that will become DataSource records. |
Boolean |
getSpoofResponses()
For a DataSource contacting a 'WSDL web service' ,
setting this flag means the DataSource doesn't actually attempt to contact the server but generates a sample response
instead, based on the XML Schema of the response message embedded in the WSDL. |
Boolean |
getUseFlatFields()
Setting useFlatFields on an operationBinding is equivalent to setting useFlatFields on all DataSource requests with the same operationType as this operationBinding . |
Boolean |
getUseHttpProxy()
Whether to use the com.smartgwt.client.rpc.RPCManager#sendProxied servlet to send requests described by this
operationBinding. |
String |
getWsOperation()
Name of the web service operation that will be invoked in order to execute this DataSource operation. |
void |
setAllowMultiUpdate(Boolean allowMultiUpdate)
Ordinarily, "update" and "remove" operations are only allowed for DataSource s that have
a 'primaryKey' , and all primary key values are present in
the request. |
void |
setCallbackParam(String callbackParam)
Applies only to dataFormat: "json". |
void |
setDataFormat(DSDataFormat dataFormat)
Format for response data for this operation. |
void |
setDataProtocol(DSProtocol dataProtocol)
Controls the format in which inputs are sent to the dataURL. |
void |
setDataTransport(RPCTransport dataTransport)
Transport to use for this operation. |
void |
setDataURL(String dataURL)
URL to contact to fulfill DSRequests for this operationBinding. |
void |
setDefaultParams(Map defaultParams)
HTTP parameters that should be submitted with every DSRequest. |
void |
setExportAs(ExportFormat exportAs)
The format in which the data should be exported. |
void |
setExportFields(String[] exportFields)
The list of field-names to export. |
void |
setExportFilename(String exportFilename)
The name of the file to save the exported data into. |
void |
setExportResults(Boolean exportResults)
When set, causes the results of the DataSource Operation to be exported to a file, whose name and format are indicated by exportFilename and
exportAs respectively. |
void |
setInvalidateCache(Boolean invalidateCache)
If set, every invocation of this operationBinding will invalidate the local cache, forcing a server visit to refresh the data. |
void |
setLineBreakStyle(String lineBreakStyle)
The style of line-breaks to use in the exported output. |
void |
setOperationId(String operationId)
Optional operationId if this DataSource supports two or more variants of one of the basic DataSource operations, for instance, a "fetch" that uses full text search and a "fetch" that accepts per-field search criteria. |
void |
setOperationType(DSOperationType operationType)
Which operationType this operationBinding is for. |
void |
setOutputs(String outputs)
Specifies, for this operationBinding only, the list of field names that should be returned to the client. |
void |
setPreventHTTPCaching(Boolean preventHTTPCaching)
Configures preventHTTPCaching on a per-operationType
basis. |
void |
setRecordName(String recordName)
For an XML DataSource, tagName of the elements to be used as records. |
void |
setRecordXPath(String recordXPath)
For an XML or JSON DataSource, XPath expression used to retrieve the objects that will become DataSource records. |
void |
setRequestProperties(DSRequest requestProperties)
Additional properties to pass through to the DSRequest created for this operation. |
void |
setResponseDataSchema(DataSource responseDataSchema)
Optional schema describing how to extract DataSource records from the XML elements selected. |
void |
setSpoofResponses(Boolean spoofResponses)
For a DataSource contacting a 'WSDL web service' ,
setting this flag means the DataSource doesn't actually attempt to contact the server but generates a sample response
instead, based on the XML Schema of the response message embedded in the WSDL. |
void |
setUseFlatFields(Boolean useFlatFields)
Setting useFlatFields on an operationBinding is equivalent to setting useFlatFields on all DataSource requests with the same operationType as this operationBinding . |
void |
setUseHttpProxy(Boolean useHttpProxy)
Whether to use the com.smartgwt.client.rpc.RPCManager#sendProxied servlet to send requests described by this
operationBinding. |
void |
setWsOperation(String wsOperation)
Name of the web service operation that will be invoked in order to execute this DataSource operation. |
void |
setXmlNamespaces(XmlNamespaces xmlNamespaces)
Optional object declaring namespace prefixes for use in OperationBinding.recordXPath and DataSourceField.valueXPath XPath expressions. |
Methods inherited from class com.smartgwt.client.core.JsObject |
---|
isCreated, setJsObj |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public OperationBinding()
public OperationBinding(JavaScriptObject jsObj)
public OperationBinding(DSOperationType operationType, String dataURL)
Method Detail |
---|
public static OperationBinding getOrCreateRef(JavaScriptObject jsObj)
public void setOperationType(DSOperationType operationType)
operationType
- operationType Default value is nullpublic DSOperationType getOperationType()
public void setOperationId(String operationId)
operationId
for usage.
operationId
- operationId Default value is nullpublic String getOperationId()
operationId
for usage.
public void setWsOperation(String wsOperation)
Valid only for
a DataSource that has a WebService (serviceNamespace
is
set). Otherwise, use dataURL
.
Setting
wsOperation
means that data
will be serialized as the
request message for the specified web service operation, with namespacing and soap encoding handled automatically. See
DataSource.transformRequest(com.smartgwt.client.data.DSRequest)
for how to customize what data is sent to the server.
wsOperation
- wsOperation Default value is nullpublic String getWsOperation()
Valid only for
a DataSource that has a WebService (serviceNamespace
is
set). Otherwise, use dataURL
.
Setting
wsOperation
means that data
will be serialized as the
request message for the specified web service operation, with namespacing and soap encoding handled automatically. See
DataSource.transformRequest(com.smartgwt.client.data.DSRequest)
for how to customize what data is sent to the server.
public void setDataURL(String dataURL)
dataURL
is typically set as
DataSource.dataURL rather than on each individual operationBinding.
dataURL
can be omitted for a
DataSource using a Web Service (serviceNamespace
is
set).
dataURL
- dataURL Default value is nullpublic String getDataURL()
dataURL
is typically set as
DataSource.dataURL rather than on each individual operationBinding.
dataURL
can be omitted for a
DataSource using a Web Service (serviceNamespace
is
set).
public void setDataProtocol(DSProtocol dataProtocol)
When a DataSource operation such as fetchData() is
invoked on this DataSource or a component bound to this DataSource, the data passed to the operation, if any, will be
sent to the dataURL
. The dataProtocol
property controls the format in which the data is sent:
SOAP message, HTTP GET or POST of parameters, etc.
The dataProtocol
property need not be set for a
DataSource with a WebService ( serviceNamespace
is set),
in this case, SOAP messaging is used by default.
Developers may completely bypass the Smart GWT comm system by
setting dataProtocol to "clientCustom"
. In this case Smart GWT will not attempt to send any data to the
server after calling DataSource.transformRequest(com.smartgwt.client.data.DSRequest)
. Instead the developer is expected to
implement transformRequest()
such that it performs the necessary data action outside of Smart GWT, and then
calls DataSource.processResponse(java.lang.String, com.smartgwt.client.data.DSResponse)
, passing in the requestId
and an appropriate set of DSResponse properties to indicate
the result of the action.
NOTE: when dataFormat
is
"iscServer", dataProtocol
is not consulted. Instead, Smart GWT uses a proprietary wire format to
communicate with the Smart GWT server, and the server-side DSRequest and DSResponse objects should be used to access
request data and form responses.
dataProtocol
- dataProtocol Default value is "getParams"public DSProtocol getDataProtocol()
When a DataSource operation such as fetchData() is
invoked on this DataSource or a component bound to this DataSource, the data passed to the operation, if any, will be
sent to the dataURL
. The dataProtocol
property controls the format in which the data is sent:
SOAP message, HTTP GET or POST of parameters, etc.
The dataProtocol
property need not be set for a
DataSource with a WebService ( serviceNamespace
is set),
in this case, SOAP messaging is used by default.
Developers may completely bypass the Smart GWT comm system by
setting dataProtocol to "clientCustom"
. In this case Smart GWT will not attempt to send any data to the
server after calling DataSource.transformRequest(com.smartgwt.client.data.DSRequest)
. Instead the developer is expected to
implement transformRequest()
such that it performs the necessary data action outside of Smart GWT, and then
calls DataSource.processResponse(java.lang.String, com.smartgwt.client.data.DSResponse)
, passing in the requestId
and an appropriate set of DSResponse properties to indicate
the result of the action.
NOTE: when dataFormat
is
"iscServer", dataProtocol
is not consulted. Instead, Smart GWT uses a proprietary wire format to
communicate with the Smart GWT server, and the server-side DSRequest and DSResponse objects should be used to access
request data and form responses.
public void setDataFormat(DSDataFormat dataFormat)
Typically set once for the DataSource as a whole via dataFormat
.
dataFormat
- dataFormat Default value is "iscServer"public DSDataFormat getDataFormat()
Typically set once for the DataSource as a whole via dataFormat
.
public void setDataTransport(RPCTransport dataTransport)
dataTransport
, which in turn defaults to com.smartgwt.client.rpc.RPCManager#defaultTransport
. This would
typically only be set to enable "scriptInclude" transport for contacting 'JSON'
web services hosted on servers other than the origin server.
When using the "scriptInclude" transport, be sure to set callbackParam
or callbackParam
to match the name of
the query parameter name expected by your JSON service provider.
dataTransport
- dataTransport Default value is RPCManager.defaultTransportpublic RPCTransport getDataTransport()
dataTransport
, which in turn defaults to com.smartgwt.client.rpc.RPCManager#defaultTransport
. This would
typically only be set to enable "scriptInclude" transport for contacting 'JSON'
web services hosted on servers other than the origin server.
When using the "scriptInclude" transport, be sure to set callbackParam
or callbackParam
to match the name of
the query parameter name expected by your JSON service provider.
public void setUseHttpProxy(Boolean useHttpProxy)
com.smartgwt.client.rpc.RPCManager#sendProxied
servlet to send requests described by this
operationBinding. If unset, automatically detects whether using the HttpProxy is necessary based on the same-origin
policy. Valid only with dataProtocol
settings
other than ISCServer.
useHttpProxy
- useHttpProxy Default value is nullpublic Boolean getUseHttpProxy()
com.smartgwt.client.rpc.RPCManager#sendProxied
servlet to send requests described by this
operationBinding. If unset, automatically detects whether using the HttpProxy is necessary based on the same-origin
policy. Valid only with dataProtocol
settings
other than ISCServer.
public void setCallbackParam(String callbackParam)
Typically set once for the DataSource as a whole via
callbackParam
.
callbackParam
- callbackParam Default value is "callback"public String getCallbackParam()
Typically set once for the DataSource as a whole via
callbackParam
.
public void setPreventHTTPCaching(Boolean preventHTTPCaching)
preventHTTPCaching
on a per-operationType
basis.
preventHTTPCaching
- preventHTTPCaching Default value is nullpublic Boolean getPreventHTTPCaching()
preventHTTPCaching
on a per-operationType
basis.
public void setUseFlatFields(Boolean useFlatFields)
useFlatFields
on an operationBinding is equivalent to setting useFlatFields
on all DataSource requests with the same operationType
as this operationBinding
.
Typical usage is to combine operationBinding.useFlatFields with 'searchForm.useFlatFields'
, with the SearchForm
bound to the WebService.getInputDS(java.lang.String)
of the
web service operation set as wsOperation
. This allows
gratuitous nesting to be consistently bypassed in both the user presentation and in the actual XML messaging.
Note
that useFlatFields
is not generally recommended for use with input messages where multiple simple type
fields exist with the same name, however if used in this way, the first field to use a given name wins. "first" means
the first field encountered in a depth first search. "wins" means only the first field will be available in data
binding, and only the first field will be populated in the generated XML message.
useFlatFields
- useFlatFields Default value is falsepublic Boolean getUseFlatFields()
useFlatFields
on an operationBinding is equivalent to setting useFlatFields
on all DataSource requests with the same operationType
as this operationBinding
.
Typical usage is to combine operationBinding.useFlatFields with 'searchForm.useFlatFields'
, with the SearchForm
bound to the WebService.getInputDS(java.lang.String)
of the
web service operation set as wsOperation
. This allows
gratuitous nesting to be consistently bypassed in both the user presentation and in the actual XML messaging.
Note
that useFlatFields
is not generally recommended for use with input messages where multiple simple type
fields exist with the same name, however if used in this way, the first field to use a given name wins. "first" means
the first field encountered in a depth first search. "wins" means only the first field will be available in data
binding, and only the first field will be populated in the generated XML message.
public void setRecordXPath(String recordXPath)
For example, an "ItemSearch" web service might return a "Results" structure containing metadata along with the set of Items that one might want to display in a grid. An XPath expression like "/Results/Items" could be used to retrieve just the Items, which would then become DataSource records.
For a JSON web service, the recordXPath
is
applied to the returned JSON data via XMLTools.selectObjects(java.lang.Object, java.lang.String)
. Only limited XPath
syntax is allowed; see XMLTools.selectObjects(java.lang.Object, java.lang.String)
for details.
For processing XML
results, see xmlNamespaces
for information on the
namespaces that are available in this XPath expression. If you are contacting a WSDL web service, note that recordName
is an alternative way to specify which records
should be selected by their tagName or type, and this is usually simpler.
To learn about XPath, try the following search: http://www.google.com/search?q=xpath+tutorial
recordXPath
- recordXPath Default value is nullpublic String getRecordXPath()
For example, an "ItemSearch" web service might return a "Results" structure containing metadata along with the set of Items that one might want to display in a grid. An XPath expression like "/Results/Items" could be used to retrieve just the Items, which would then become DataSource records.
For a JSON web service, the recordXPath
is
applied to the returned JSON data via XMLTools.selectObjects(java.lang.Object, java.lang.String)
. Only limited XPath
syntax is allowed; see XMLTools.selectObjects(java.lang.Object, java.lang.String)
for details.
For processing XML
results, see xmlNamespaces
for information on the
namespaces that are available in this XPath expression. If you are contacting a WSDL web service, note that recordName
is an alternative way to specify which records
should be selected by their tagName or type, and this is usually simpler.
To learn about XPath, try the following search: http://www.google.com/search?q=xpath+tutorial
public void setRecordName(String recordName)
This is a simple alternative to recordXPath
when the elements to be used as records all share
a tagName.
When a DataSource has a WebService, recordName
can also be set to the name of any
complexType
declared within the WebService's WSDL file.
recordName
- recordName Default value is nullpublic String getRecordName()
This is a simple alternative to recordXPath
when the elements to be used as records all share
a tagName.
When a DataSource has a WebService, recordName
can also be set to the name of any
complexType
declared within the WebService's WSDL file.
public void setSpoofResponses(Boolean spoofResponses)
'WSDL web service'
,
setting this flag means the DataSource doesn't actually attempt to contact the server but generates a sample response
instead, based on the XML Schema of the response message embedded in the WSDL. The spoofed response will include all complexType elements and will fill in appropriate values by type for all simpleType elements, although the spoofed data will not conform to all xs:restriction declarations (eg xs:pattern).
Note that if your WSDL does not fully describe
the response format (some WSDL services just have a placeholder <xs:any> element), Smart GWT can only produce a
partial response. To use a hand-generated sample response, just save an XML file to disk and use the dataURL
setting to point to it.
spoofResponses
- spoofResponses Default value is falsepublic Boolean getSpoofResponses()
'WSDL web service'
,
setting this flag means the DataSource doesn't actually attempt to contact the server but generates a sample response
instead, based on the XML Schema of the response message embedded in the WSDL. The spoofed response will include all complexType elements and will fill in appropriate values by type for all simpleType elements, although the spoofed data will not conform to all xs:restriction declarations (eg xs:pattern).
Note that if your WSDL does not fully describe
the response format (some WSDL services just have a placeholder <xs:any> element), Smart GWT can only produce a
partial response. To use a hand-generated sample response, just save an XML file to disk and use the dataURL
setting to point to it.
public void setExportResults(Boolean exportResults)
exportFilename
and
exportAs
respectively. When no exportFilename is provided, the
default is Results and the default value of exportAs is csv. Once the Operation
completes,
exportDisplay
specifies whether the
exported data will
be downloaded to the file-system or displayed in a new window. The
default value of exportDisplay is "download"
which displays the Save As dialog. See
ExportDisplay
for more information.
The export field-list can also be configured, see exportFields
.
You can also configure the style of line-breaks to use when generating the output.
See
com.smartgwt.client..LineBreakStyle
for more information.
As well as setting this and
other properties on the OperationBinding
, Exports can be
initiated in two other
ways. You can set properties on the dsRequest by passing
requestProperties into com.smartgwt.client.data.DataSource#exportData
. Note that this method does
not support exporting to JSON format
(see
this post for more detail).
Additionally, custom server code may set export-related properties on the
DSResponse
.
Format Examples
XML format
<List> <Object> <id>10101</id> <displayName>Record 10101</displayName> </Object> </List>JSON Format
[ { id: 10101, displayName: "Record 10101" } ]CSV Format
id,displayName 10101,"Record 10101"
exportResults
- exportResults Default value is falsepublic Boolean getExportResults()
exportFilename
and
exportAs
respectively. When no exportFilename is provided, the
default is Results and the default value of exportAs is csv. Once the Operation
completes,
exportDisplay
specifies whether the
exported data will
be downloaded to the file-system or displayed in a new window. The
default value of exportDisplay is "download"
which displays the Save As dialog. See
ExportDisplay
for more information.
The export field-list can also be configured, see exportFields
.
You can also configure the style of line-breaks to use when generating the output.
See
com.smartgwt.client..LineBreakStyle
for more information.
As well as setting this and
other properties on the OperationBinding
, Exports can be
initiated in two other
ways. You can set properties on the dsRequest by passing
requestProperties into com.smartgwt.client.data.DataSource#exportData
. Note that this method does
not support exporting to JSON format
(see
this post for more detail).
Additionally, custom server code may set export-related properties on the
DSResponse
.
Format Examples
XML format
<List> <Object> <id>10101</id> <displayName>Record 10101</displayName> </Object> </List>JSON Format
[ { id: 10101, displayName: "Record 10101" } ]CSV Format
id,displayName 10101,"Record 10101"
public void setExportAs(ExportFormat exportAs)
ExportFormat
for more information.
exportAs
- exportAs Default value is "csv"public ExportFormat getExportAs()
ExportFormat
for more information.
public void setExportFilename(String exportFilename)
exportFilename
- exportFilename Default value is nullpublic String getExportFilename()
public void setLineBreakStyle(String lineBreakStyle)
com.smartgwt.client..LineBreakStyle
for more
information.
lineBreakStyle
- lineBreakStyle Default value is nullpublic String getLineBreakStyle()
com.smartgwt.client..LineBreakStyle
for more
information.
public void setAllowMultiUpdate(Boolean allowMultiUpdate)
DataSource
s that have
a 'primaryKey'
, and all primary key values are present in
the request. This is because an update of a DataSource with no primary key, or an update request that has missing
primary key values, cannot be guaranteed to affect only one record. Setting this property on an operationBinding circumvents this restriction for that operation only.
Warning: Be aware that this is a potentially dangerous setting and should be used with care. With this flag set, you have no guarantee that an update will not change or remove every row in a table.
allowMultiUpdate
- allowMultiUpdate Default value is nullpublic Boolean getAllowMultiUpdate()
DataSource
s that have
a 'primaryKey'
, and all primary key values are present in
the request. This is because an update of a DataSource with no primary key, or an update request that has missing
primary key values, cannot be guaranteed to affect only one record. Setting this property on an operationBinding circumvents this restriction for that operation only.
Warning: Be aware that this is a potentially dangerous setting and should be used with care. With this flag set, you have no guarantee that an update will not change or remove every row in a table.
public void setInvalidateCache(Boolean invalidateCache)
invalidateCache
- invalidateCache Default value is nullpublic Boolean getInvalidateCache()
public void setOutputs(String outputs)
fields
, but note that this is not a
requirement; outputs
can include fields that are not defined in the DataSource's field list. In this case,
the server will return extra fields even if dropExtraFields
is true. You specify this property as a string containing a comma-separated list of field names (eg, "foo, bar, baz")
outputs
- outputs Default value is nullpublic String getOutputs()
fields
, but note that this is not a
requirement; outputs
can include fields that are not defined in the DataSource's field list. In this case,
the server will return extra fields even if dropExtraFields
is true. You specify this property as a string containing a comma-separated list of field names (eg, "foo, bar, baz")
public void setExportFields(String[] exportFields)
If exportFields is not provided, the exported output includes all visible fields from the DataSource (field.hidden=false), sorted in the order they're defined.
exportFields
- exportFields Default value is nullpublic String[] getExportFields()
If exportFields is not provided, the exported output includes all visible fields from the DataSource (field.hidden=false), sorted in the order they're defined.
public void setXmlNamespaces(XmlNamespaces xmlNamespaces)
xmlNamespaces
- xml namespaces
IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic void setDefaultParams(Map defaultParams)
defaultParams
- the default paramspublic void setRequestProperties(DSRequest requestProperties)
DSRequest
created for this operation. Note that these will be cumulative
with and will override on a per-property basis any properties set via DataSource.requestProperties.
DataSource.transformRequest(com.smartgwt.client.data.DSRequest)
is called.
requestProperties
- the request properties. Default is null.public void setResponseDataSchema(DataSource responseDataSchema)
responseDataSchema
- the response schema. Default is null
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |