OpenWGA 7.0 - OpenWGA Concepts and Features

Design and development » WebTML » Basic concepts » Design References

Local references

Local references are a way to address design resources that are stored in the same folder as the calling resource.

Design resources in OpenWGA can be organized in subfolders. It is good programming practice to store design resources that belong to the same functionality in the same folder. For example: The WebTML module "projects:portlet" may have accompanying modules which define its code for different portlet modes like "view", "new" and "edit". These may get stored under "projects:mode-view", "projects:mode-new" and "projects:mode-edit".

Local references are an easy and safe way to address these other design resources that belong to the same functionality without specifying the folder.

A local reference starts with a double colon "::". This double colon represents the folder that the current design resource is contained in. After the double colon the name of the addressed design may be specified. So specifying the following include inside WebTML module "projects:portlet":

<tml:include ref="::mode-view"/>

Would indeed perform the following:

<tml:include ref="projects:mode-view"/>

This also works across different resource types, even if they are stored under differing base folders. So creating the following action link inside WebTML module "projects:portlet":

<tml:button clickaction="::createproject">Create project</tml:button>

Would indeed equal the following:

<tml:button clickaction="projects:createproject">Create project</tml:button>

This calls the code of TMLScript module "projects:createproject", even though the WebTML module may be stored in file "/tml/html/projects/portlet.tml" while the script module resides under "/scripts/tmlscript/projects/createproject.tmlscript". So the "projects" folders are not actually the same, but the structure below the base folders is equal.

In special cases you may actually just want to specify the double colon without any following design name, if you want to address a resource whose name equals your current folder name. For example this inside "projects:portlet":

<tml:url doc="::" file="icon.png"/>

Will retrieve a file "icon.png" from a file container simply named "projects:

<tml:url doc="projects" file="icon.png"/>


A selection of other places in WebTML where local references are allowed:

<tml:include ref="::module" linkaction="::action"/>


<tml:url type="css/js" name="::script" doc="::script"/>


<tml:url type="tml/content" layout="::module"/>


<tml:url type="action" action="::action"/>


<tml:action ref="::action"/>


<tml:button clickaction="::action"/>


<tml:input changeaction="::action"/>

Some places in TMLScript allowing local references:

WGA.callAction("::scriptmodule");

 

WGA.createObject("::scriptmodule"); 


WGA.design().loadObjectDefinition("::scriptmodule")