...
Tip | ||
---|---|---|
| ||
Data sources and formatters are fully extensible to allow you to add new functionality. You can define your own dataSource and formatter extension classes. <formatter class="com.acme.formatters.PhoneNumberFormatter" id="digitFormatter"/> In addition, you can package extensions as plug-ins, allowing you to declare alternative tag names. Custom formatter and dataSource objects are discussed below. Let's first make note of what any formatter and dataSource does. |
Data Sources
A dataSource's main responsibilities include:
...
The out-of-box data framework provides the following dataSources:
...
Tip | ||
---|---|---|
| ||
By supplying a Managed Client Object (MCO) method as the source attribute, you can cache data by retrieving and storing it in a data cache (Hashtable), then returning the existing data rather than making another request to the server for the same data. The method below will cache an XML document from the salesforce.jsp page mentioned in the previous Helpful Tip. /** A documentDataSource can then call this method through: <data:documentDataSource |
Tip | ||
---|---|---|
| ||
Using Nexaweb Studio, you can easily create data sources by dragging and dropping XML files into its visual editor. Once data sources are supplied they will be accessible from wizards and from outline views of other XML UI files. |
...
Iterators
Iterators provide functionality for creating complex UI structures such as tables, lists, and so forth. By nesting iterators, you can create even more complex structures such as trees and tree tables. An Iterator replicates its children for each item in a set of data. The dataSource and select attributes of the iterator tag define the set of data. The following example shows an iterator creating a complex UI structure of panels and buttons within a scrollPane.
...
Custom code
First, create a class that extends the AbstractJavaFormatter class. This class implements the Formatter interface and handles initialization. Then, implement the class' formatObject method; this method performs the actual formatting of the supplied object into a new one.
...
To try this code, create an XML file called data.xml that has <data phoneNumber="1234567890"/> as its content.
Tip | ||
---|---|---|
| ||
Since the incoming object can be of many possible types, you will need to use the type conversion service supplied to change the incoming object of the formatObject method into a type with which your code can easily work. The interface TypeConversionService encapsulates functionality for changing types. Convert the incoming object instance by calling ClientSession.getTypeConversionService.convertToString(incomingObject). |
Putting it all together
Using Nexaweb data framework along with Nexaweb Studio's functionality can greatly reduce the amount of code needed to integrate your application with any back end data sources. Look for ways to effectively use one way data binding within applications. For example, you can implement one way data binding of shared XML documents. You can modify shared XML documents from the server, thus automatically synchronizing changes and triggering UI updates without the need to write any client side code.
...