X

Shay Shmeltzer's Oracle Development Tools Tips

Adding LOV to non-database Field or Parameters

Shay Shmeltzer
Director of Product Management - Oracle

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.

Join the discussion

Comments ( 9 )
  • guest Friday, May 25, 2012

    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


  • guest Tuesday, May 29, 2012

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


  • guest Thursday, August 2, 2012

    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


  • guest Thursday, August 9, 2012

    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


  • Dave Jarvis Wednesday, January 30, 2013

    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.


  • guest Friday, July 5, 2013

    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.


  • shay Tuesday, July 16, 2013

    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.


  • Oralover Thursday, February 11, 2016

    hi Shay,

    i am new to learn ADF, i am PL-SQL developer and most of the ADF work is creating user interfaces. i also made few Forms on Developer Forms 10g and in ADF i failed to find reorder / rearrange columns in its layout panel by using my mouse like i can do it in Forms 10g ( i am nooooob ). please find below what i want to do and help me to do so. i am using Oracle ADF/JDeveloper 12.2.1.

    example:

    ADF generated by default like this:

    Employee ID: 001

    First Name: John

    Last Name: Smith

    Job: 08

    Department: 10

    Salary: 1000

    Commission: 3

    Can I reorder / re-arrange as below or as I want to, using my mouse at design time?

    Employee ID: 001 First Name: John Last Name: Smith

    Job: Sales Person



    Department: Sales

    Salary: 1000 Commission %: 3

    Total: ( formula: 1000+(1000*3)/100


  • guest Thursday, January 19, 2017

    Hi shay,

    i Created Input LOV suggested by your Post, but when i am trying to access it's throwing error saying that "ADF FACES-60096:Server Exception during PPR, #6".

    Please advice.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.