Data Service Binding

Requires Platform 4.2+

Requires Data Service Plugin

DataService Syntax

This document describes the declarative syntax for using the com.nexaweb.data.DataService interface for binding data to the UI. The com.nexaweb.data.DataService interface is a system service provided through a plug-in. See the Data Service Plugin API javadoc for more information.

The following methods are exposed for binding data to the UI using the "DataService" system service.

Important: The following methods return generic Objects that can be used with the text resolution syntax or as method call arguments.

DataService.bind( 'bind-string' )

Bind using the specified bind-string.

where bind-string: a semi-colon delimited list of parameters.

where Parameter format: name/value pairs separated by equals (name=value).

The following table lists the supported parameters for the bind-string:

ParameterDescriptionRequired

type

Binding type: ONE_TIME or ONE_WAY

If not supplied, defaults to ONE_TIME

Optional
dataSource

The ID of a data source, or in the context of an iteration loop, this may be the name of an ancestor iterator. If not supplied the select will be executed relative to the parent iterator.

Required

defaultValue

The value to be returned when the data is unavailable or null.

Optional
formatter the formatter to use to alter the data for presentation in the ui 

Example

 <label text="{ bind('dataSource=myDataSource; select=/customers/customer[0]@name; type=ONE_WAY') }"/>

Registered Shortcut

bind
bind
=DataService.bind

DataService.bind( binding://binding-id )

Bind using the binding definition with ID binding-id.

Example

 <label text="{ bind(binding://myBinding) } 

Registered Shortcut

bind
bind
=DataService.bind

DataService.relativeBind( 'select' )

Bind using the specified select string. The binding executes against the data source for the closest iterator ancestor, supplying the current iteration data as the context for the select.

Example

 <data:iterator dataSource="myDataSource" select="/customers" xmlns:data="http://nexaweb.com/data">
  <label text="{ *('customer[0]@name') }"/>
 </data:iterator>

Registered Shortcut

*
* for DataService.relativeBind

DataService.relativeBind( 'iteratorNameOrDataSourceId', 'select' )

Bind using the specified select string. The binding executes relative to the current iteration of the iterator ancestor named iteratorNameOrDataSourceId, or directly against the specified data source with id iteratorNameOrDataSourceId without context.

Example: 

<data:iterator name="topIterator" dataSource="myDataSource" 
     select="/customers" xmlns:data="http://nexaweb.com/data">
  <label text="{ *('topIterator', 'customer[0]@name') }"/>
</data:iterator>

 

Registered Shortcut

*
* for DataService.relativeBind