resourceURI()

The resourceURI() function builds the URI to images or resources.

In snippets, we include the different picture components using the snippet-based rendering engine (SBRE) function resourceURI(value,pictureId). These examples identify the behavior of this function. To illustrate the different cases, snippets fragments are used here, based on the following application configuration. The current output map is the DUA_AJAX map.
<?xml version="1.0"?>
<APPLICATION Parent="defaultgwc"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="http://www.4js.com/ns/gas/2.21/cfextwa.xsd">
  <OUTPUT>
    <MAP Id="DUA_HTML5">
     <PICTURE>
         <PATH Id="Resources" Type="WEBSERVER">/pic</PATH>
         <PATH Id="Image" Type="APPSERVER" ExtensionFilter=".png;.gif">
               $(res.path.pic);$(application.path)</PATH>
         <PATH Id="SetHtml5" Type="APPSERVER" ExtensionFilter=".png;.js;.css" 
           DVMFallbackAllowed="FALSE">$(res.path.tpl.html5);$(res.path.tpl.common)
         </PATH>
      </PICTURE>
    </MAP>
  </OUTPUT>
</APPLICATION>
  1. If value is an absolute URL (such as http://www.mycompany.com/favicon.ico), regardless of the pictureId is used, the value is directly returned.

    resourceUri("http://www.mycompany.com/favicon.ico", "whatever") = 
      http://www.mycompany.com/favicon.ico
  2. If pictureId refers to a WEBSERVER path, the path value is handled as a prefix, and the value is appended to this prefix to build the returned value.
    resourceUri("myImage.png", "Resources") = /pic/myImage.png
  3. For the rest of the cases, the pictureId refers to an APPSERVER path. If the resource identified by value is found in one of the directories listed in the PATH element, and if the resource has an extension that match an extension listed in the ExtensionFilter attribute (or if the ExtensionFilter attribute is not present at all), a /wa/i URL will be built.
    resourceUri("myImage.png", "Image") = /wa/i/card/Image/DUA_AJAX/myImage.png
    The generated URL is composed by a prefix (wa/i), an application ID (appName or groupName/appName), an output map ID (DUA_AJAX), and the resource name (value). This means that all application sessions share the same resources, as it is the case with GDC images.

    If the resource value do not have extension, extension completion will be made according to FGL standards.

  4. If the resource is not found locally, and if the DVMFallbackAllowed attribute is not set to FALSE, the resource is retrieved by the DVM. In this case, a file transfer URL is built that uniquely identifies the resource.

    resourceUri("myImage.png", "Image") = /wa/ft/<sessionID>/<fileTransferID>
Note: Using an invalid pictureId (undefined) will raise a snippet rendering error.