Thursday, December 8, 2011

Create Description Attribute of an LOV Attribute. Using Reference Entities. ADF BC 11g

Hi,
In this example we are going to create a simple LOV and we are going to have an additional attribute as the description of that LOV.

Download Sample Application.

In more detail, we are going to use two entities in one View Object. The first entity will be our updatable entity. The second entity is going to be the reference Entity. The role of the second entity is to provide a description of the id if the first entity.

So, basically we are going to have an LOV which will display meaningles ids and another attribute from another entity that will display the description of that id. The description will be a meaningfull message to the user.
For this example we are going to use the HR Schema and the following tables:

Locations,
Countries.

We want to show a form of Locations and we want to have the Country Id from an LOV.

First we will create the Business Components with the wizard of JDeveloper.

This will produce us all the BC:



We simply left the Location View Object only. We removed all other views in the Application module.
We want to show the Country name for the corresponding Country Id.
Additionally we want to have the CountryId as an LOV.
Lets Create the LOV

First, we locate the attribute we want, CountryId in our case in the LocationsView vo and we press the  plus sign in the LOV section. On the new window, we press the plus sign again in order to set the List Data Source. In the new window(again) we shuttle on the right the CountriesView vo and we press ok:




Next, we have to map the attributes we want to associate:



Last but not list, is the apperance of the  List of the Values. We select the UI Hints in the same window and we shuttle the attributes we want to have them displayed in the list of values. Additionally, we set the type of the List to Input Text with List of Values.



And that is about it. our lov is created. The next step is to associate our Locations entity with our Countries entities in the Same viewObject, the LocationsView.
We go to LocationsView and more specifically in the Data Model. We shuttle the Countries entity to the right and we will see that the association is applied immediatelly. We select the join to be outer join just in the case of no data.


Now that we have our entity, we are going to shuttle our desired attribute, which is the CountryName. Now that we have added the Countries entity we can shuttle CountryName from that entity. If we havent done that, we would not be able to show this attribute in the LocationsView.





And we press OK.
As you might have noticed above, we shuttled only one attribute, the CountryName and the PK is additionally shuttled. This is needed because the framework needs to update the association for every new value in the main CountryId from the Locations Entity.

From the BC point of view, all  the mandatory steps are done.
Off to create our jspx!
For this example we are going to create a simple jspx form to our unbounded task flow. We are simply going to drag and drop our LocationsView iterator from the datacontrol to our jspx as a form:


In the new window we are going to select the attributes that we want to display in our form. As you will see in the wizard, we will have the additiona CountryId1 attribute from the reference entity. we will remove that because we dont want to have duplicate components.
NOTE: we could prevent this in the BC layer and the Display Hint attribute. The scope of this example is simply illustrative and aims to demonstrate the description functionality.


As you see, we have the CountryId1 attribute to be displayed. We simply select it and press the red x button to remove it from the list. Another important think to notice here is that the wizard understood from the BC that the type of the List for the CountryId is List of Values and immediatelly converts it to the corresponding component.
We press OK and after adding some additional buttons with operations we have our form.



But we are not quite there... a few adjustments left.
In order to properly display the CountryName in every change of the CountryId we have to make the CountryId LOV to AutoSubmit=true and place partialTriggers to the CountryName. The partial Trigger will be the id of the CountryId LOV component.

AutoSubmit:


PartialTriggers:



And That is it!
Every time we change value in our CountryId the CountryName will be updated accordingly.

Download Sample Application.

Regards.

3 comments:

  1. hi Dimitrios Stasinopoulos.

    In this thread.our discussion goes here.
    https://forums.oracle.com/forums/edit!default.jspa?messageID=10122498

    ReplyDelete
  2. remove that link.

    this is that thread.
    https://forums.oracle.com/forums/thread.jspa?threadID=2319228&tstart=0

    ReplyDelete
  3. Finally understand how LOV works in ADF thanks

    ReplyDelete

LinkWithin

Related Posts Plugin for WordPress, Blogger...