Configuring a Choice Control to Use Data from an MBO

Configuring a choice control whose items come from a data source

This task refers to the choice control configuration in the PurchaseOrderSample sample application, to illustrate several steps. The Sybase Unwired Platform sample applications are available at https://cw.sdn.sap.com/cw/groups/sup-apps.
  1. Create a Mobile Business Object using a data source that defines the data to be included in the choice control.
    Example: in the sample application, the PurchaseOrderApprover MBO uses the PurchaseOrderApprover table.
  2. In the Mobile Application Diagram, select the MBO. In the MBO properties, define an object query that accesses the records you want to use in your choice control.
    Example: in the sample application, the PurchaseOrderApprover MBO defines a query with these values:
    • Name: findByName
    • Return type: Multiple objects
    • Create an index: selected
    • Query definition: SELECT x.* FROM PurchaseOrderApprover x WHERE x.name LIKE :parameter1
    Note: The parameter is resolved later, when the operation that invokes this query passes in its value.
  3. Deploy the project.
  4. Open the deployed XBW package file in the Mobile Workflow Forms Editor and add the screens for your application.
  5. In your application's flow design, open the screen that will contain your choice control. Add the key that you will bind to the choice control:
    1. In the Keys page, click New.
    2. In the Key dialog, enter the name of the key you want to use. Select list as the type, and select the options, Enable Sent by server and MBO object query results.
    3. Click OK.
    Example: the sample application uses the key, PurchaseOrderApprover_findByName_resultSetKey, for the choice control.
  6. In your MBO screen design, add a menu item from the Palette to the menu box.
  7. Select the new menu item and configure its properties:
    1. In the General properties page, specify the menu item name.
    2. Choose the operation type.
      These operations can invoke an online query:
      • Online Request
      • Submit Workflow
      • Add Key Collection
      • Update Key Collection
      • Delete Key Collection
    3. Specify the Mobile business object associated with the menu action.
    4. Enable the option, Invoke object query, and choose the object query.
    5. In the Parameter Mappings properties page, select each parameter from the selected object query, then click Edit to map the parameter to an available key.
    Example: the sample application invokes the findByName query, and binds parameter1 to the approverNamePattern key.
  8. Add a choice control from the Palette to the MBO screen design. Select the new control and edit its properties to define data bindings:
    1. Specify the label name and position.
    2. Under Input Data Binding, click the Key control. Then select one of the available keys or specify a new key.
      Example: the sample application binds PurchaseOrder_create_purchaseOrderApproverID_paramKey.
    3. Enable the Dynamic option. Bind each field to the key that you created in the screen's flow design.
    Example: the sample application uses these keys:
    • Value key - PurchaseOrderApprover_findByName_resultSetKey.PurchaseOrderApprover_ID_attribKey
    • Display name key - PurchaseOrderApprover_findByName_resultSetKey.PurchaseOrderApprover_name_attribKey
  9. Save your form.