Programmatic Data Binding

Since each UI components’ ability to display data can differ quite significantly, RapidClipse offers three different types of data containers:

  • Container (table): Can save a list of records (items).
  • Item (record): Can save one record that consists of multiple properties.
  • Property (single value): Can save only one single value.

Container 

A container can hold a list with any number of data records (BeanItems). RapidClipse offers two different container types: The XdevLazyEntityContainer and the XdevBeanItemContainer.


XdevBeanItemContainer 

The XdevBeanItemContainer is the standard data container for custom queries.

  • Does not provide fully automated lazy loading between the database and the server, but does provide it between the server and the client. The entire query result is cached in the XdevBeanItemContainer. The query result has to be minimized by using common query terms.  
  • It is possible to manually add records (BeanItems).
  • Used by RapidClipse when Entity > Data > findAll is selected in the properties of a UI component.
Summary:
Data containerMethodsExplanationExampleUI-Komponenten
XdevBeanItemContainersetContainerDataSourceAssign the XdevBeanItemContainer to a UI component
table.setContainerDataSource(productContainer);
  • XdevTable
  • XdevComboBox
  • XdevListSelect
  • XdevTwinColSelect
  • XdevTree
  • XdevTreeTable
getContainerDataSourceReturn the XdevBeanItemContainer from a UI component
XdevBeanItemContainer<Product> productContainer = table.getContainerDataSource();
Examples:
  • Save query result in the XdevBeanItemContainer

    Creates a new selectProducts DAO object to perform the SELECT * FROM products database query by using the findAll method. Runs the query and saves the result in the productList list..

    ProductDAO selectProducts = new ProductDAO();
    List<Product> productList = selectProducts.findAll();

    This creates a new XdevBeanItemContainer product container of the type Product and assigns the productList list that contains the query to the addAll method.

    XdevBeanItemContainer<Product> productContainer = new XdevBeanItemContainer<Product>(Product.class); 
    productContainer.addAll(productList);
  • Primary keys - Returns a list of all primary keys

    Collection<?> itemIds = table.getContainerDataSource().getItemIds();


  • Value via ID - Returns the value with ID 5.

    Product selProduct = table.getContainerDataSource().getItem(5).getBean();
  • Clear XdevBeanItemContainer

    table.getContainerDataSource().removeAll();

XdevLazyEntityContainer 

The XdevLazyEntityContainer is only used by RapidClipse if Entity > Auto query data is selected in the properties of a UI component.

  • Provides fully automated lazy loading between the database, server, and client. Only the records that are requested by the client by scrolling or paging are transferred between the database and the server.
  • No dynamic SQL queries are possible (SELECT * FROM ... is always automatically selected)
  • It is not possible to manually add BeanItems.
Model for:

Item 

An item can hold a list of properties (individual values) and, thus, only one record. By default, RapidClipse uses the BeanItem item expansion. 

Chai10 boxes x 20 bags18390false10
Summary:
Data containerMethodsExplanationExampleUI components
BeanItemgetItemDataSourceReturn the BeanItem from a UI component
BeanItem<Product> itemDataSource = fieldGroup.getItemDataSource();
  • XdevFieldGroup

setItemDataSource

Assign BeanItem to a UI component

fieldGroup.setItemDataSource(product);
Model for:
Examples:
  • Instantiate BeanItem

    BeanItem<Product> product = new BeanItem<Product>(null);
  • Read selected line from XdevTable

    BeanItem<Product> product = table.getSelectedItem();
  • Assign a record to a form - The setItemDataSource method is used to assign a record to a form.

    fieldGroup.setItemDataSource(product);

Property

A property can only accept a single value (data field). 

Chai
Summary:
Data containerMethodsExplanationExampleUI component
PropertygetPropertyDataSourceGet the value of the UI component.
Property<?> propertyDataSource = this.label.getPropertyDataSource();
  • XdevTextField
  • XdevPasswordField
  • XdevInlineDateField
  • XdevPopupDateField
  • XdevNativeSelect
  • XdevRichTextArea 
  • XdevLabel
  • XdevCheckBox

setPropertyDataSource

Assign value to a UI component.

label.setPropertyDataSource("text");
Model for: 


Examples: 
  • Instantiate property

    Property<String> productName = new ObjectProperty<String>("Chai");
  • Read data field from a selected line of an XdevTable

    Property<String> productName = product.getItemProperty("productname");
  • Assign value to an XdevTextField
    • Assignment by using the setPropertyDataSource method:

      textField.setPropertyDataSource(productName);
    • Assign using the setValue method:

      textField.setValue(productName);

Workflow from data input to visualization


                                              

XDEV Software Corp. - One Embarcadero Center, San Francisco, CA 94111, US
Copyright © 2015. XDEV Software Corp. All rights reserved.