Class RemoteInclude
dw.system
Class RemoteInclude
Object
dw.system.RemoteInclude

The class represents a remote include value that can be assigned to JSON Object properties.


Important notes:

  • Authentication and authorization checks are performed only for the top level request, but NOT for remote include requests.
  • Correct rendering of RemoteInclude-containing objects is only performed when processed by
    dw.system.RESTSuccessResponse.render()
    method. Please check the provided examples.

    Example 1. Specify remote include properties.

     function specifyRemoteIncludeProperties() {
        var includeValue0 = dw.system.RESTResponseMgr.createScapiRemoteInclude("custom", "sample", "v1", "resource/path/0", dw.web.URLParameter("siteId", "TestWapi"));
        var includeValue1 = dw.system.RESTResponseMgr.createScapiRemoteInclude("custom", "sample", "v1", "resource/path/1", dw.web.URLParameter("siteId", "TestWapi"));
        var greeting = { "hello": "world", "includeProperty0": includeValue0, "includeProperty1": includeValue1 };
    
        dw.system.RESTResponseMgr.createSuccess(greeting).render();
     }
     

    Example 2. Specify array of remote include properties.

     function specifyArrayOfRemoteIncludes() {
       var includeValue0 = dw.system.RESTResponseMgr.createScapiRemoteInclude("custom", "sample", "v1", "resource/path/0", dw.web.URLParameter("siteId", "TestWapi"));
       var includeValue1 = dw.system.RESTResponseMgr.createScapiRemoteInclude("custom", "sample", "v1", "resource/path/1", dw.web.URLParameter("siteId", "TestWapi"));
       var greeting = { "hello": "world", "includeArray": [includeValue0, includeValue1] };
    
       dw.system.RESTResponseMgr.createSuccess(greeting).render();
     }
     

    Example 3. Storefront controller remote include.

    function storefrontRemoteInclude()
    {
        let remoteInclude = dw.system.RESTResponseMgr.createStorefrontControllerRemoteInclude(new URLAction("Category-Show", "Sites-MyShop-Site", dw.web.URLParameter("cid", "root")));
        let json = {
            status: "JSONOK",
            include: remoteInclude
        };
        dw.system.RESTResponseMgr.createSuccess(json).render();
    }
     

    Error handling:
    SCAPI:
  • In case of 404 response received on included resource, empty JSON object '{}' will be supplied in final JSON.
  • In case of any other 4xx, 5xx response from included resource, final response status will be 500 'Internal Server Error'.
    Controllers:
  • The error response is directly embedded into the resulting JSON. Thus please ensure that your error responses are always valid JSON, otherwise final response will be invalid JSON.
  • Properties
    url  :  String  (Read Only)
    The URL string value specified for the current instance.
    Constructor Summary
    This class does not have a constructor, so you cannot create it directly.
    Method Summary
    getUrl() : String
    Returns the URL string value specified for the current instance.
    toString() : String
    Returns the URL string value specified for the current instance, same as getUrl().
    valueOf() : Object
    Returns the URL string value specified for the current instance, same as getUrl().
    Method Detail
    getUrl
    getUrl() : String
    Returns the URL string value specified for the current instance.

    toString
    toString() : String
    Returns the URL string value specified for the current instance, same as getUrl().

    valueOf
    valueOf() : Object
    Returns the URL string value specified for the current instance, same as getUrl().