Adding LOV to non-database Field or Parameters

More and more people end up using ADF for applications that don't actually talk to a database backend but rather to Web services, Java classes, and SOA process instead. In these cases the ADF pages actually end up invoking methods and passing parameters to these methods. One question I got today was "how do I add a database driven LOV to such a parameter?".

The tricky part is that the LOV component - af:inputListOfValues - expects a specific data model to be able to show the advance searching the LOV offers. As a lazy developer I don't feel like creating a managed bean with this model and populating it manually from the database. Instead here is a little video that shows a no-coding possible solution.

I'm using ADF BC to get the LOV and data from the database. I then use a bit of binding trickery to eliminate the need for a managed bean with the model structure for the LOV. I associate the LOV model created for an ADF BC field with an LOV field that is mapped to the parameter being passed to the method.

Comments:

Thank you Shay, this is great. I only wish you posted this about a week ago, I would have saved quite some time I spent creating dual-based view objects with a bunch of transient attributes :-)

Also, I believe you can safely delete the LOV field you commented out as long as you do it in the source file (as opposed to the structure window).

Rasto

Posted by guest on May 25, 2012 at 05:42 AM PDT #

Same can be achieved directly by using Model LOV just putting #{viewScope.p1} in 'value' property.

Posted by guest on May 29, 2012 at 06:44 AM PDT #

This is great!
I just have a question. Suppose the list of values are in thousands and
you only want to display 10 at a time with the navigation buttons(previous, next), how would you do that?
Thanks!
Binh

Posted by guest on August 02, 2012 at 01:20 PM PDT #

This is in response to the question I have about how to display the list of values 10 items at a time with the navigation buttons instead of displaying the whole list.

Thank you Shay,
Binh

Posted by guest on August 09, 2012 at 06:45 AM PDT #

There is an easier way.

# Solution

You have to:

- Create a view object to be programmatic, with the desired attributes.
- Configure the view object with validation rules.
- Configure the Application Module.
- Create the web page form.
- Update the page binding to create a new row.

# Create View Object

Create the view object as follows:

1. Type <kbd>Control+n</kbd> to open the **New Gallery**.
1. Search for and select **View Object**.
1. Click **OK**.
1. Set **Package**, **Name**, and **Display Name** appropriately.
1. Set **Data Source** to **Programmatic**.
1. Click **Next**.
1. Click **New** and provide a meaningful attribute name.
1. Click **OK**.
1. Add the remaining attributes.
1. Click **Next**.
1. Set **Updatable** to **Always** for all attributes.
1. Set **Type** to the appropriate data type.
1. Click **Finish**.

# Configure Validation Rules

Configure the validation rules as follows:

1. Click the **Attributes** finger tab.
1. Select the desired attribute.
1. Click the **Validation Rules** tab.
1. Click the **+** icon within the **Validation Rules** section.
1. Set the **Rule Definition** as required.
1. Set the **Error Message** as required.
1. Repeat to add as many validation rules as necessary.

At this point a view object has been configured and the **List of Values** tab can be used to reference query-based LOVs.

# Configure Application Module

Configure the application module as follows:

1. Double click the application's application module.
1. Select the **Data Model** finger tab.
1. Shuttle the view object from **Available View Objects** to **Data Model**.
1. Remove the **1** suffix.
1. Save the application.

Note: If the view object is not visible, restart JDeveloper.

# Create Web Page Form

Create a web page for the form as follows:

1. Create a new JSF page for the view object.
1. Refresh the **Data Controls** to see the view object instance.
1. Drag and drop the view object onto the page.
1. Select **Form » ADF Form**.
1. Check **Include Submit Button**.
1. Click **OK**.

The web page is created.

# Update Page Binding

The attributes for the view object cannot be changed unless there is a "row" created for the view object instance. Creating this in-memory row must happen before the page content is displayed. Accomplish this as follows:

1. Expand the Data Controls to reveal the view object's **Operations**.
1. Drag **Create** into the footer facet.
1. Select **ADF Button**.
1. Right-click on the page.
1. Select **Go to Page Definition**.
1. Click **+** beside **Executables**.
1. Select **invokeAction**.
1. Click **OK**.
1. Set **id** to: create
1. Set **Binds** to: Create
1. Click OK.
1. Set Refresh to: **prepareModel**
1. Save all.

Validation is applied and data-driven LOVs can be used.

Remove the "Create" button.

Posted by Dave Jarvis on January 30, 2013 at 11:49 AM PST #

hi shay i am ur follower,

I have one doubt,how to create LOV for one field in my form that is created from data control from db.But i hav to give datasource as List from managed bean to that LOV not from any viewaccesor.

Simply i asking you how to create LOV from Managed Bean method as Datasource to give List of values.

thanking you.

Posted by guest on July 05, 2013 at 01:06 AM PDT #

guest - the ADF Faces components demo that you can download from the ADF Faces page has an example of the source needed to define an LOV based on a managed bean structure without ADF Binding.

Posted by shay on July 16, 2013 at 08:43 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

me
I'm a Director of Product Management for the Oracle Java Development Tools.
Follow me:
Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today