com.smartgwt.client.data

Class RestDataSource

    • Constructor Detail

      • RestDataSource

        public RestDataSource()
      • RestDataSource

        public RestDataSource(com.google.gwt.core.client.JavaScriptObject jsObj)
    • Method Detail

      • getOrCreateRef

        public static RestDataSource getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
      • create

        public com.google.gwt.core.client.JavaScriptObject create()
        Overrides:
        create in class DataSource
      • setAddDataURL

        public void setAddDataURL(java.lang.String addDataURL)
                           throws java.lang.IllegalStateException
        Custom dataURL for add type operations
        Parameters:
        addDataURL - Default value is null
        Throws:
        java.lang.IllegalStateException - this property cannot be changed after the underlying component has been created
      • getAddDataURL

        public java.lang.String getAddDataURL()
        Custom dataURL for add type operations
        Returns:
        String
      • setDisableQueuing

        public void setDisableQueuing(java.lang.Boolean disableQueuing)
        If set, disables request queuing for this RestDataSource.
        Parameters:
        disableQueuing - Default value is false
      • getDisableQueuing

        public java.lang.Boolean getDisableQueuing()
        If set, disables request queuing for this RestDataSource.
        Returns:
        Boolean
      • setFetchDataURL

        public void setFetchDataURL(java.lang.String fetchDataURL)
                             throws java.lang.IllegalStateException
        Custom dataURL for fetch type operations
        Parameters:
        fetchDataURL - Default value is null
        Throws:
        java.lang.IllegalStateException - this property cannot be changed after the underlying component has been created
      • getFetchDataURL

        public java.lang.String getFetchDataURL()
        Custom dataURL for fetch type operations
        Returns:
        String
      • setJsonPrefix

        public void setJsonPrefix(java.lang.String jsonPrefix)
        Allows you to specify an arbitrary prefix string to apply to all json format responses sent from the server to this application. The client will expect to find this prefix on any JSON response received for this DataSource, and will strip it off before evaluating the response text.

        The default prefix is "<SCRIPT>//'\"]]>>isc_JSONResponseStart>>".

        The inclusion of such a prefix ensures your code is not directly executable outside of your application, as a preventative measure against javascript hijacking.

        You can switch off JSON wrapping altogether by setting both this and jsonSuffix to empty strings.

        If you are using Smart GWT Server's RESTHandler servlet, see the server-side Javadocs for details of how to change the way JSON wrapping works on the server side.

        Overrides:
        setJsonPrefix in class DataSource
        Parameters:
        jsonPrefix - Default value is See below
        See Also:
        setJsonSuffix(java.lang.String)
      • getJsonPrefix

        public java.lang.String getJsonPrefix()
        Allows you to specify an arbitrary prefix string to apply to all json format responses sent from the server to this application. The client will expect to find this prefix on any JSON response received for this DataSource, and will strip it off before evaluating the response text.

        The default prefix is "<SCRIPT>//'\"]]>>isc_JSONResponseStart>>".

        The inclusion of such a prefix ensures your code is not directly executable outside of your application, as a preventative measure against javascript hijacking.

        You can switch off JSON wrapping altogether by setting both this and jsonSuffix to empty strings.

        If you are using Smart GWT Server's RESTHandler servlet, see the server-side Javadocs for details of how to change the way JSON wrapping works on the server side.

        Overrides:
        getJsonPrefix in class DataSource
        Returns:
        String
        See Also:
        getJsonSuffix()
      • setJsonRecordXPath

        public void setJsonRecordXPath(java.lang.String jsonRecordXPath)
                                throws java.lang.IllegalStateException
        recordXPath mapping to the data node of json returned by the server. Applies if this.dataFormat is set to "json"
        The default value will pick up data from a response structured as follows:
          {response:
           {status:0,
            data:[
               {field1:"value", field2:"value"},
               {field1:"value", field2:"value"}
            ]
          }
          
        Parameters:
        jsonRecordXPath - Default value is "/response/data"
        Throws:
        java.lang.IllegalStateException - this property cannot be changed after the underlying component has been created
      • getJsonRecordXPath

        public java.lang.String getJsonRecordXPath()
        recordXPath mapping to the data node of json returned by the server. Applies if this.dataFormat is set to "json"
        The default value will pick up data from a response structured as follows:
          {response:
           {status:0,
            data:[
               {field1:"value", field2:"value"},
               {field1:"value", field2:"value"}
            ]
          }
          
        Returns:
        String
      • setJsonSuffix

        public void setJsonSuffix(java.lang.String jsonSuffix)
        Allows you to specify an arbitrary suffix string to apply to all json format responses sent from the server to this application. The client will expect to find this suffix on any JSON response received for this DataSource, and will strip it off before evaluating the response text.

        The default suffix is "//isc_JSONResponseEnd".

        Overrides:
        setJsonSuffix in class DataSource
        Parameters:
        jsonSuffix - Default value is See below
        See Also:
        setJsonPrefix(java.lang.String)
      • getJsonSuffix

        public java.lang.String getJsonSuffix()
        Allows you to specify an arbitrary suffix string to apply to all json format responses sent from the server to this application. The client will expect to find this suffix on any JSON response received for this DataSource, and will strip it off before evaluating the response text.

        The default suffix is "//isc_JSONResponseEnd".

        Overrides:
        getJsonSuffix in class DataSource
        Returns:
        String
        See Also:
        getJsonPrefix()
      • setMetaDataPrefix

        public void setMetaDataPrefix(java.lang.String metaDataPrefix)
                               throws java.lang.IllegalStateException
        If sendMetaData is true, this attribute is used to specify the prefix to apply to 'meta data' properties when assembling parameters to send to the server. Applies to operations where OperationBinding.dataProtocol is set to "getParams" or "postParams" only.
        Parameters:
        metaDataPrefix - Default value is "_"
        Throws:
        java.lang.IllegalStateException - this property cannot be changed after the underlying component has been created
      • getMetaDataPrefix

        public java.lang.String getMetaDataPrefix()
        If sendMetaData is true, this attribute is used to specify the prefix to apply to 'meta data' properties when assembling parameters to send to the server. Applies to operations where OperationBinding.dataProtocol is set to "getParams" or "postParams" only.
        Returns:
        String
      • setOperationBindings

        public void setOperationBindings(OperationBinding... operationBindings)
                                  throws java.lang.IllegalStateException
        RestDataSource OperationBindings set to specify default dataProtocol per operationType. Default databindings are:
            operationBindings : [
              {operationType:"fetch", dataProtocol:"getParams"},
              {operationType:"add", dataProtocol:"postParams"},
              {operationType:"remove", dataProtocol:"postParams"},
              {operationType:"update", dataProtocol:"postParams"} 
            ],
          
        If you are integrating with a REST server that requires the more obscure httpMethods of "PUT", "DELETE" or "HEAD", you can specify these httpMethod settings via requestProperties. dataProtocol settings that mention "GET" or "POST" are compatible with these additional HTTP methods as well. Typical operationBindings for a REST server that uses "PUT" and "DELETE" are as follows:
            operationBindings:[
              {operationType:"fetch", dataProtocol:"getParams"},
              {operationType:"add", dataProtocol:"postParams"},
              {operationType:"remove", dataProtocol:"getParams", requestProperties:{httpMethod:"DELETE"}},
              {operationType:"update", dataProtocol:"postParams", requestProperties:{httpMethod:"PUT"}}
            ],
          

        Note that dataProtocol:"postMessage" is always used when queuing is used to send multiple DSRequests to the server as a single HttpRequest. See RestDataSource docs, "queuing support". We also recommend that you use the "postMessage" protocol whenever you are intending to use AdvancedCriteria with RestDataSource - this is discussed in the section "Server inbound data format" in the RestDataSource overview.

        Overrides:
        setOperationBindings in class DataSource
        Parameters:
        operationBindings - Default value is [...]
        Throws:
        java.lang.IllegalStateException - this property cannot be changed after the underlying component has been created
        See Also:
        OperationBinding
      • getOperationBindings

        public OperationBinding[] getOperationBindings()
        RestDataSource OperationBindings set to specify default dataProtocol per operationType. Default databindings are:
            operationBindings : [
              {operationType:"fetch", dataProtocol:"getParams"},
              {operationType:"add", dataProtocol:"postParams"},
              {operationType:"remove", dataProtocol:"postParams"},
              {operationType:"update", dataProtocol:"postParams"} 
            ],
          
        If you are integrating with a REST server that requires the more obscure httpMethods of "PUT", "DELETE" or "HEAD", you can specify these httpMethod settings via requestProperties. dataProtocol settings that mention "GET" or "POST" are compatible with these additional HTTP methods as well. Typical operationBindings for a REST server that uses "PUT" and "DELETE" are as follows:
            operationBindings:[
              {operationType:"fetch", dataProtocol:"getParams"},
              {operationType:"add", dataProtocol:"postParams"},
              {operationType:"remove", dataProtocol:"getParams", requestProperties:{httpMethod:"DELETE"}},
              {operationType:"update", dataProtocol:"postParams", requestProperties:{httpMethod:"PUT"}}
            ],
          

        Note that dataProtocol:"postMessage" is always used when queuing is used to send multiple DSRequests to the server as a single HttpRequest. See RestDataSource docs, "queuing support". We also recommend that you use the "postMessage" protocol whenever you are intending to use AdvancedCriteria with RestDataSource - this is discussed in the section "Server inbound data format" in the RestDataSource overview.

        Overrides:
        getOperationBindings in class DataSource
        Returns:
        OperationBinding...
        See Also:
        OperationBinding
      • setPrettyPrintJSON

        public void setPrettyPrintJSON(java.lang.Boolean prettyPrintJSON)
                                throws java.lang.IllegalStateException
        When using dataFormat:"json" and dataProtocol:"postMessage" should we use the prettyPrint feature to enable indented, highly readable JSON messages.

        True by default because the bandwidth involved is generally negligible and the benefits for troubleshooting are key.

        Parameters:
        prettyPrintJSON - Default value is true
        Throws:
        java.lang.IllegalStateException - this property cannot be changed after the underlying component has been created
      • getPrettyPrintJSON

        public java.lang.Boolean getPrettyPrintJSON()
        When using dataFormat:"json" and dataProtocol:"postMessage" should we use the prettyPrint feature to enable indented, highly readable JSON messages.

        True by default because the bandwidth involved is generally negligible and the benefits for troubleshooting are key.

        Returns:
        Boolean
      • setRemoveDataURL

        public void setRemoveDataURL(java.lang.String removeDataURL)
                              throws java.lang.IllegalStateException
        Custom dataURL for remove type operations
        Parameters:
        removeDataURL - Default value is null
        Throws:
        java.lang.IllegalStateException - this property cannot be changed after the underlying component has been created
      • getRemoveDataURL

        public java.lang.String getRemoveDataURL()
        Custom dataURL for remove type operations
        Returns:
        String
      • setSendMetaData

        public void setSendMetaData(java.lang.Boolean sendMetaData)
                             throws java.lang.IllegalStateException
        Should operation meta data be included when assembling parameters to send to the server? If true, meta data parameters will be prefixed with the metaDataPrefix.
        Applies to operations where OperationBinding.dataProtocol is set to "getParams" or "postParams" only.
        Parameters:
        sendMetaData - Default value is true
        Throws:
        java.lang.IllegalStateException - this property cannot be changed after the underlying component has been created
      • getSendMetaData

        public java.lang.Boolean getSendMetaData()
        Should operation meta data be included when assembling parameters to send to the server? If true, meta data parameters will be prefixed with the metaDataPrefix.
        Applies to operations where OperationBinding.dataProtocol is set to "getParams" or "postParams" only.
        Returns:
        Boolean
      • setUpdateDataURL

        public void setUpdateDataURL(java.lang.String updateDataURL)
                              throws java.lang.IllegalStateException
        Custom dataURL for update type operations
        Parameters:
        updateDataURL - Default value is null
        Throws:
        java.lang.IllegalStateException - this property cannot be changed after the underlying component has been created
      • getUpdateDataURL

        public java.lang.String getUpdateDataURL()
        Custom dataURL for update type operations
        Returns:
        String
      • setXmlNamespaces

        public void setXmlNamespaces(XmlNamespaces xmlNamespaces)
                              throws java.lang.IllegalStateException
        When dataFormat is "xml", xmlNamespaces configures the set of namespace prefixes that are added to the document element of the XML message sent to the server. Format is the same as xmlNamespaces.

        By default, the "xsi" prefix is bound to "http://www.w3.org/2001/XMLSchema-instance" in order to allow explicit null values in Records to be sent for fields declared nillable. Set to null to avoid any prefixes being added.

        Overrides:
        setXmlNamespaces in class DataSource
        Parameters:
        xmlNamespaces - Default value is See below
        Throws:
        java.lang.IllegalStateException - this property cannot be changed after the underlying component has been created
        See Also:
        DataSourceField.setNillable(java.lang.Boolean)
      • getXmlNamespaces

        public XmlNamespaces getXmlNamespaces()
        When dataFormat is "xml", xmlNamespaces configures the set of namespace prefixes that are added to the document element of the XML message sent to the server. Format is the same as xmlNamespaces.

        By default, the "xsi" prefix is bound to "http://www.w3.org/2001/XMLSchema-instance" in order to allow explicit null values in Records to be sent for fields declared nillable. Set to null to avoid any prefixes being added.

        Returns:
        XmlNamespaces
        See Also:
        DataSourceField.getNillable()
      • setXmlRecordXPath

        public void setXmlRecordXPath(java.lang.String xmlRecordXPath)
                               throws java.lang.IllegalStateException
        recordXPath mapping to the data node of XML returned by the server. Applies if this.dataFormat is set to "xml".
        The default value will pick up data from a response structured as follows:
          <response>
             <status>0</status>
             <data>
               <record>
                   <field1>value</field1>
                   <field2>value</field2>
               </record>
               <record>
                   <field1>value</field1>
                   <field2>value</field2>
               </record>
             </data>
          </response>
          
        Parameters:
        xmlRecordXPath - Default value is "/response/data/*"
        Throws:
        java.lang.IllegalStateException - this property cannot be changed after the underlying component has been created
      • getXmlRecordXPath

        public java.lang.String getXmlRecordXPath()
        recordXPath mapping to the data node of XML returned by the server. Applies if this.dataFormat is set to "xml".
        The default value will pick up data from a response structured as follows:
          <response>
             <status>0</status>
             <data>
               <record>
                   <field1>value</field1>
                   <field2>value</field2>
               </record>
               <record>
                   <field1>value</field1>
                   <field2>value</field2>
               </record>
             </data>
          </response>
          
        Returns:
        String