Building Mobile Enterprise Applications : webMethods Mobile Development Help : Building the User Interface for a Mobile Application : Using a Content Adapter to Populate a ListView
Using a Content Adapter to Populate a ListView
You can populate a ListView object using a ContentProvider object to retrieve data from a data source. The ContentProvider is designed to initialize one given type of Template and bound it against the underlying data, provided by the data source. However, this approach enables developers to quickly setup a ListView object, but is limited, because only one type of Template can be populated. The ContentAdapter has been introduced to close this gap and to populate multiple types of Templates to a ListView object. More information, see Using a Content Provider to Populate a ListView.
Note:  
Instead of using a ContentAdapter, you can programmatically populate the ListView. For more information, see Programmatically Populating a ListView.
To add a ContentAdapter to the ListView or ListViewElement:
1. Add a ListView object to your application or use a Template containing a ListViewElement object.
2. Add a data source to your application, as a child of the Datasources node. This can be a DynamicDataSource, a RESTDataSource or a EntityDataSource.
3. Add a ContentAdapter object to the ListView object. The ContentAdapter object indicates from where you obtain data. Set the following properties:
Property
Description
List Data Source
Required. Specifies the data source.
No Rows Template
Optional. A Template that is to be shown when the data source of the ContentAdapter contains no elements.
Reload On Transition To
Optional. Select this if the ContentAdapter is to be reloaded each time this view is accessed.
4. Add one or more TemplateAssignment to the ContentAdapter. The TemplateAssignment configures the Template to display. Set the following properties:
Property
Description
BindMethodName
Optional. A name of a Java method will be generated. The generated contents will initialize your Template and bind it against the data.
This method is overwriteable in your ListView controller implementation.
Filter Expression
Required. A string value evaluated at runtime, if the specified Template should be initialized for a given row index.
Template
Required. A Template used to show the contents of the ListView.
5. Add one or more TemplateDataBinding objects to the TemplateAssignment object. A TemplateDataBinding maps a control contained in the Template of the TemplateAssignment with a given set of data identified by the Expression property. Set the following properties:
Property
Description
Control
Required. Select a control that is contained in the Template of the TemplateAssignment. The control must have a name.
Data Source
Required. Select the data source to populate the data for this control.
Expression
Required. Enter an expression value to identify the data.
6. Optional. Add one or more RowSelectionListener to the ContentAdapter to react on the user interaction with the ListView. A RowSelectionListener also has a property filterExpression. This will act like the filterExpression, set for a TemplateAssignment, and indicates, which of the RowSelectionListeners needs to be triggered, when the user selects on row of the ListView.
Copyright © 2007-2017 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback