Load, refresh and fetch actions

You can use the load and refresh actions to control the initial loading of the widget content, and to refresh the content periodically.

You can use the load and refresh actions to control the initial loading of the widget content, and to refresh the content periodically.

The fetch action allows you to import XML data from the external source, transform it into format acceptable by the XDIME application and present it on a device via AJAX.

Load action

You can use the widget:load element to load the data from an external source. It also allows authors to defer the loading of the data, so that it is only loaded when the user requests it. Normally you do this because the content may take a while to load, and might cause an unacceptable delay in sending the content to the client.

You provide the relative URL from which the update can be retrieved in the src attribute, and use the when attribute to specify the timing. The value 'onload' means that as soon as the client has loaded the page, it starts loading in the content in the background; this setting should be used for content that will almost certainly be needed by the user. The 'defer' setting means that the client will defer loading the content until it is actually requested; this should be used for content that is less likely to be needed immediately.

<widget:folding-item>
  <widget:summary>Vienna</widget:summary>
  <widget:detail>
    <widget:load src="service/folding-item?itemId=Vienna"/>
  </widget:detail>
</widget:folding-item>

Refresh action

You can use the widget:refresh action to update content of the widget. The src attribute specifies the URL from which the update can be retrieved, relative to the containing page, and the interval attribute sets the minimum interval between content refreshes, expressed as a number of seconds. Initially the timer starts from the moment the widget is created, and subsequently it starts from after the widget's content has been updated.

<widget:ticker-tape id="myWeatherTicker">
  <widget:refresh src="service/ticker?id=myWeatherTicker" interval="15"/>
  <span>Ticker Tape can be configured to periodically refresh its content
    by fetching data, such as weather conditions, from a web service...</span>
</widget:ticker-tape>

Fetch action

It allows authors to import an XML data from an external source, specified by the src attribute, and transform it into format acceptable by the XDIME application using XSL transformation. Finally, it loads the content, in a form of the XDIME response, on a device using AJAX.

The widget:fetch element has the following additional attributes: transformation defines the URL address of the XSL stylesheet, transform-cache and transform-compile specify if transformation should be cached and compiled, respectively. The service attribute sets URL to the fetch service. It must be specified if the fetch service location is different than the default one, defined in the web.xml file.

<widget:block>	            
  <widget:fetch src="http://xml.weather.yahoo.com/forecastrss?p=HUXX0002&amp;u=c"
    when="onload" transformation="weather-presenter.xsl"
    service="/projects/client-app/servicefetch"/>
</widget:block>

Related topics