Part 3: Add a List of Values

Work in JDeveloper's IDE to add List-of-Values (LOV) components to the pages.

Create a Static View Object: Use the Create View Object wizard to add a static view object to the business services.

Create a Static LOV: Use the Data Controls panel to add a Single Selection | ADF Select One Choice component to create the LOV on a page.

Create a Lookup View Object: Use the Create View Object wizard to add a dynamic view object to the business services.

Create a Dynamic LOV: Use the Data Controls panel to add a dynamic LOV to a page.

 

Create a Static View Object

tell me more icon Creating a Static View Object

A static LOV is based on a view object where transient attributes are created and populated at design time. You will define a view object, populate it with the static values needed for the LOV and associate it with the view object that will use it as an LOV.  [ tell me more...]





  1. In the Application Navigator, select the Model project and launch the Create View Object wizard [ File > New > Business Tier > ADF Business Components > View Object] .
  2. Enter StatusCodes as the name of the view object.
  3. Select Rows popula ted at design time (Static List) , and click Next .
  4. On step 2, click N ew . In the New View Object Attribute dialog, enter Status as the name of the attribute and select Key Attribute . Then click OK.
  5. Click N ew again. Enter Description as the name of the attribute, and click OK. Then click Next twice.
  6. On step 4, click add Add seven times to add seven blank rows. Then create the static list values by entering the values for Status and Description as shown here:
                                       
    PENDING  Order has been submitted
    SHIP     Order is being shipped
    PICK     Order is being picked
    COMPLETE Order complete
    CANCEL   Order was cancelled
    STOCK    Order is waiting for stock
    CART     Order is in cart
                                    
  7. Click Next to display the Application Module page. Select Application Module to have the new view added to the FODModule application module. Then click Finish .

    tell me more icon Defining a Static List of Values

    When you define a static list for a view object, JDeveloper creates a standard message bundle file in which to store them. The file is specific to the view object component to which it is related, and it is named accordingly. Internationalizing the model layer of an application built using ADF Business Components entails producing translated versions of each component's message bundle file. For example, the Italian version of the ModelBundle.properties message bundle would be a class named ModelBundle_it.properties, and a more specific Swiss Italian version would have the name ModelBundle_it_ch.properties.  [ tell me more...]



  8. In the editor window, click the OrdersView.xml tab to bring the overview editor forward. (If the file is not already open, double-click OrdersView in the Model project in the Application Navigator to open it in the overview editor.)
  9. Select the View Accessors tab.
  10. To set the StatusCodes view object, click add Add. Select StatusCodes in the A vailable View Objects pane and shuttle shuttle it to the View Accessors pane. Then click OK.
  11. Select the Attributes tab, then select the OrderStatusCode attribute. Below the attributes table, click add Add next to List of Values: OrderStatusCode.
  12. In the Create List of Values dialog, select StatusCodes1 from the List Data Source dropdown list. Select Status from the List Attribute dropdown list.
  13. Click the UI Hints tab.
  14. Select Description in the A vailable pane and shuttle shuttle it to the Selected pane.
  15. Deselect Include "No Selection" Item .
  16. Click OK to close the List of Values dialog.

    tell me more icon In the IDE

    When you add the view object as a view accessor, it should look like this:  [ tell me more...]



 

Create a Static LOV

tell me more icon Creating a Static LOV

A static LOV is based on a view object where transient attributes are created and populated at design time. You will assign the view object to a specific attribute that requires an LOV and choose how the LOV will be displayed. You then edit a page to display the attribute as an LOV list.   [ tell me more...]





  1. In the editor window, click the editOrders.jspx tab to bring the page forward.
  2. Select the OrderStatusCode input text field and delete it.
  3. In the Data Controls panel, click refresh icon Refresh.
  4. Expand the FODModuleDataControl | OrdersView1 node. Select the OrderStatusCode attribute and drag it to the right of the OrderShippedDate field on the page, dropping the attribute in its previous location (between OrderShippedDate and OrderTotal).
  5. From the Create context menu, choose Single Selection then choose ADF Select One Choice .

    tell me more icon Model Driven List

    The status codes are displayed as a choice list in the LOV UI. With a choice list, other options are available: you can display multiple columns in the LOV (in this example, the status code); and also allow the user to leave the selection blank. You also could have used a different LOV UI, for instance a combo box or a radio group.   [ tell me more...]



  6. Click save all Save All to save your work.

    tell me more icon In the IDE

    In the edit page, an LOV is available next to the OrderStatusCode label:  [ tell me more...]



 

Create a Lookup View Object

tell me more icon Creating a Lookup View Object

A dynamic LOV is based on a view object which provides the SQL to populate the list of values. You will define the view object and specify the query that will used as the basis for the LOV in this case, retrieving all the customers. Once you've configured a view object to provide a list of values for a given field, you can easily allow that list to be used for validation. In this example, you can ensure that the CustomerId value that a user enters in the editOrders form is a valid CustomerId, that is, a value that is in the list of values.   [ tell me more...]





  1. In the Application Navigator, select the Model project and launch the Create View Object wizard [ File > New > Business Tier > ADF Business Components > View Object] .
  2. Enter CustomerView as the name of the view object.
  3. Select Rea d-only access through SQL query . Then click Next .
  4. On step 2, enter the following in the Query Statement box:
    SELECT * from PERSONS Persons
    WHERE Persons.PERSON_TYPE_CODE = 'CUST'
  5. Click Test to test the query and click OK when the "query is valid" message displays. Then click Next until you reach step 6 of the wizard: Attribute Settings.
  6. On step 6, make sure PersonId is selected in the Se lect Attribute dropdown list, and select Key Attribute . Then click Next until you reach step 8: Application Module.
  7. On step 8, select Application Module . Then click Finish .
  8. In the editor window, click Orders.xml to bring the file forward. (If the file is not already open, double-click Orders in the Model project in the Application Navigator to open it in the overview editor.)
  9. In the overview editor, select the View Accessors tab.

    tell me more icon Lookup View Objects

    The new view object can be added as a view accessor in the View Accessors dialog, available by clicking the View Accessors tab in the overview editor for entity objects.   [ tell me more...]



  10. Click add Add to open the View Accessors dialog. Select CustomerView in the A vailable View Objects panel and shuttle shuttle it to the View Accessors panel. Then click OK.
  11. In the Orders.xml overview editor, select the Attributes tab, then select the CustomerId attribute. Below the attributes table, click add Add next to the Validation Rules item.
  12. In the Add Validation Rule dialog, select Key Exists from the Rule Type dropdown list.
  13. Select View Accessor from the Va lidation Target Type dropdown list.
  14. Select CustomerId in the Ord ers Entity Attributes panel and PersonId (under CustomerView1) in the Valida tion Target Attributes panel. Click Add .
  15. Then click OK.
  16. Click OK to continue without defining an error message.

    tell me more icon In the IDE

    You created a view object that can be used as the provider for a list of values in the user interface. That view object also serves as a list of valid values in the validation of the CustomerId field.  [ tell me more...]



 

Create a Dynamic LOV

tell me more icon Creating a Dynamic LOV

You will use the dynamic view object (a view object populated from a SQL query) created earlier as the basis for a list of values. You will remove the CustomerId field from the form, and replace the field with an inputListOfValues component. This component displays as an input text field, with a button next to it which can be activated to display the list of values in a separate window. You will configure the list of values to display a subset of columns from the view object, and specify the relationship between the field and the value selected from the list.   [ tell me more...]





  1. In the editor window, click the OrdersView.xml tab to bring it forward, and select the Attributes tab.
  2. Select the CustomerId attribute. Below the attributes table, click add Add next to the List of Values item to create an LOV for this attribute.
  3. In the Create List of Values dialog, select Orders.CustomerView1 from the List Data Source dropdown list. When prompted by a warning dialog, click OK. Then select PersonId from the List Attribute dropdown list.
  4. Select the UI Hints tab.
  5. Select the following attributes in the A vailable pane and shuttle shuttle them to the Selected pane, in this order: PersonId, FirstName, LastName, Email, Gender.
  6. Click OK to close the dialog.
  7. In the editor window, click the editOrders.jspx tab to bring the page forward.
  8. Select the input text field for CustomerId and delete it.

    tell me more icon Dynamic LOVs

    Using the Data Controls panel, you can add an ADF LOV Input for CustomerId to the page, replacing the inputText field for CustomerId after you delete it.  [ tell me more...]



  9. In the Data Controls panel, click refresh icon Refresh.
  10. Expand the FODModuleDataControl | OrdersView1 nodes. Select the CustomerId attribute and drag it onto the page, dropping it in its previous location.
  11. From the Create context menu, choose List of Values then choose ADF LOV Input .
  12. In the editor window, click the orders-flow.xml tab to bring the diagram forward. Right-click the browseOrders page icon and choose R un .

    tell me more icon In the IDE

    You added an inputListOfValues component to the editOrders.jspx form. At runtime clicking on the LOV button activates the list of values, from which you can select a value for the field from a user-friendly interface.  [ tell me more...]



 

cue cards iconNext step

 

Copyright © 1997, 2009, Oracle. All rights reserved.

false ,,,,,,,,,,,,,,,