Part 3: Add a List of Values

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

Create a Static View Object: Create a static view object for the status code values.

Create a Static LOV: Create a static LOV for the order status code field on the edit page, so the order status description is displayed in a dropdown list box.

Create a Lookup View Object: Create a lookup view object for the Customer Id field, so that customer names can be displayed instead of customer id values on the edit page.

Create a Dynamic LOV: Create a dynamic LOV for the Customer Id field on the edit page, so the customer name is displayed in a dropdown list box.

Test the LOV: Run the application in the IDE and try out the choice lists.

 

Create a Static View Object

tell me more icon Creating a Static View Object

A static LOV (list of values) is based on a view object where transient attributes are created and populated with values at design time. You will define a new view object, populate it with the static values needed for the LOV, and associate it with the existing 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. On step 1 of the wizard, enter StatusCodes as the view object name. Select Rows popula ted at design time (Static List) , and click Next .
  3. 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.
  4. Click N ew again. Enter StatusDesc as the name of the attribute and click OK. Then click Next twice.
  5. On step 4, click green add icon Add seven times to add seven blank rows. Then create the static list values by entering the values for Status and StatusDesc as shown here:
                                       
    PENDING  Order submitted
                                        
    SHIP Order being shipped
    PICK Order being picked
    COMPLETE Order completed
    CANCEL Order cancelled
    STOCK Waiting for stock
    CART Order in cart
  6. Click Next . On step 5, 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, if not already created, JDeveloper creates a standard message bundle file in which to store the values. The message bundle 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...]



  7. In the Application Navigator, model project, double-click OrdersView.xml to open the view object in the overview editor.
  8. Select the View Accessors tab. To set the StatusCodes view object, click green add icon Add.
  9. In the View Accessors dialog, select StatusCodes in the A vailable View Objects pane and shuttle icon shuttle it to the View Accessors pane. Then click OK.

    tell me more icon In the IDE

    After adding the StatusCodes view object as a view accessor to the OrdersView view object, the View Accessors page of the overview editor 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. In the previous cue card, you created a list of codes in the static view object StatusCodes and associated the view object with the OrdersView view object through a view accessor. In this cue card, you will enable OrdersView to be used as the provider for the static LOV in the user interface. For OrdersView to use the static list in StatusCodes as an LOV, first you have to configure OrdersView to use an LOV.   [ tell me more...]





  1. If not already in focus, click the OrdersView.xml tab in the editor window to bring the file forward.
  2. Select the Attributes tab, then select the OrderStatusCode attribute. Below the table of attributes, click green add icon Add next to List of Values: OrderStatusCode.
  3. In the Create List of Values dialog, accept the default name. On the Configuration tabbed page, select StatusCodes1 from the List Data Source dropdown list. Then select Status from the List Attribute dropdown list.

    tell me more icon Creating the List of Values

    To configure the user interface for the LOV-enabled attribute ( OrderStatusCode), you specify the view accessor that supplies the list data at runtime, and the attribute that is the data source for the list.  [ tell me more...]



  4. Click the UI Hints tab. Accept Choice List as the default list type.
  5. Select StatusDesc in the A vailable pane and shuttle icon shuttle it to the Selected pane.
  6. Deselect Include "No Selection" Item . Then click OK.
  7. In the editor window, click the ed-o.jspx tab to bring the page forward.
  8. Select the OrderStatusCode input text field (between OrderShippedDate and OrderTotal), then delete it.
  9. In the Data Controls panel, click refresh icon Refresh.
  10. Expand the FODModuleDataControl | OrdersView1 nodes. Drag the OrderStatusCode attribute to the Structure window and drop it in its previous location, that is, directly below tr:inputText - OrderShippedDate.
  11. From the Create context menu, choose Single Selection then choose Trinidad Select One Choice.

    tell me more icon Model-Driven List

    A model-driven list is based on an LOV that is bound to a view data object.   [ tell me more...]



  12. Click save Save All to save your work.

    tell me more icon In the IDE

    After defining the OrderStatusCode attribute in OrdersView as the LOV-enabled attribute, the Attributes page of the overview editor should look like this:  [ 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 where a SQL statement is used to populate the list of values. You will define a new view object and specify a query that retrieves all customers to use as the basis for the 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. On step 1 of the wizard, enter CustomerView as the name of the view object. Select Rea d-only access through SQL query , and click Next .
  3. On step 2, enter the following in the Query Statement box:
    SELECT * from PERSONS Persons
    WHERE Persons.PERSON_TYPE_CODE = 'CUST'
  4. Click Test to test the query and click OK when the "query is valid" message displays. Then click Next until you reach step 6: Attribute Settings.
  5. On step 6, make sure PersonId is selected in the Se lect Attribute dropdown list. Select Key Attribute , then click Next until you reach step 8: Application Module.
  6. On step 8, select Application Module . Then click Finish .
  7. In the Application Navigator, double-click Orders in the model project to open the entity object in the overview editor. Select the View Accessors tab and click green add icon Add.

    tell me more icon Lookup View Objects

    The View Accessors dialog is available from the View Accessors tab in the entity object overview editor when you click green add icon. Use the View Accessors dialog to add the new view object CustomerView as a view accessor to the Orders entity object.  [ tell me more...]



  8. In the View Accessors dialog, select CustomerView in the A vailable View Objects pane and shuttle icon shuttle it to the View Accessors pane. Then click OK.

    tell me more icon In the IDE

    In the Application Navigator, the model project contains CustomerView, the new SQL-only view object you created that has read-only access to the database:  [ tell me more...]



 

Create a Dynamic LOV

tell me more icon Creating a Dynamic LOV

A dynamic LOV is based on a view object where a SQL statement is used to populate the list of values at runtime. In the previous cue card, you created the lookup view object ( CustomerView) based on a query that retrieves all customers for use as the basis for the list of values. You also made the lookup view object available to the Orders entity object by adding it through a view accessor.   [ tell me more...]





  1. In the editor window, click the OrdersView.xml tab to bring the file forward. Select the Attributes tab, then select the CustomerId attribute.
  2. Below the table of attributes, click green add icon Add next to List of Values: CustomerId to create an LOV for this item.
  3. In the Create List of Values dialog, accept the default name. On the Configuration tabbed page, select Orders.CustomerView1 from the List Data Source dropdown list. When prompted by a warning dialog, click OK.
  4. Select PersonId from the List Attribute dropdown list.
  5. Click the UI Hints tab. Accept Choice List as the default list type.
  6. Select the following attributes in the A vailable pane and shuttle icon shuttle them to the Selected pane, in this order: FirstName, LastName.

    tell me more icon Dynamic LOVs

    Dynamic LOVs are selection lists generated dynamically at runtime based on one or more databound attributes.   [ tell me more...]



  7. Deselect Include "No Selection" Item . Then click OK.
  8. In the editor window, click the ed-o.jspx tab to bring the page forward.
  9. Select the CustomerId input text field (between OrderTotal and ShipToName), then delete it.
  10. In the Data Controls panel, click refresh icon Refresh.
  11. Expand the FODModuleDataControl | OrdersView1 nodes. Drag the CustomerId attribute to the Structure window and drop it in its previous location, that is, directly below tr:inputText - OrderTotal.
  12. From the Create context menu, choose Single Selection then choose Trinidad Select One Choice.
  13. In the Property Inspector for the Select One Choice you just added, change the Label property value to CustomerName and press Enter.

    tell me more icon In the IDE

    When you complete the steps for replacing the original CustomerId input text field on the edit page with the new LOV-enabled CustomerId attribute, the page in the visual editor should look similar to this:   [ tell me more...]



 

Test the LOV

tell me more icon Testing the LOV

You can run your application in the IDE by right-clicking the br-o.jspx page and choosing R un from the context menu.   [ tell me more...]





  1. In the Application Navigator, mvc project, right click br-o.jspx and choose R un .
  2. In the running application, click Edit to navigate to the ed-o.jspx page.
  3. Try out the two new selection components you added: the choice list for OrderStatusCode and  CustomerName.

    tell me more icon In the IDE

    When you click the OrderStatusCode choice list on the ed-o.jspx page, the page in a desktop web browser should look similar to this:   [ tell me more...]



 

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

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