Showing posts with label LOV. Show all posts
Showing posts with label LOV. Show all posts

Sunday, 17 February 2013

Creating an LOV which is detached from entity model/DB in ADF


      This post explains how to create an LOV which is detached from entity model (no database or business component validation for insertion should happen on change of the drop down value).


         To demonstrate this, let us consider a login screen which will have user name, password as input text fields and a drop down to select the county whose value will be stored in session for later use (the list of countries should be populated from database but the selection in the UI should not have effect on the database).

1) Let us create a view object for country table.
2) Once the view object is created , Create the LOV for country Id by clicking on attributes à List of values.





3)     In loginpageDef.xml add an executable (iterator).


4) Go to structure of loginpageDef.xml and add variables under executables

5) Create a variable countryIdVar under the variables


6) Now in login.jspx, drag and drop countryName from data controls

7)   Give the proper values (base data source as variables and list data source as data control.

Friday, 15 February 2013

Accessing selected value of LOV (drop down) in ADF

Problem:
How to access the selected value of a LOV (drop down) in managed bean (java class) programatically.

Solution:

1) Write a value change listener for the LOV.
2) Get the Iterator of the LOV from bindings.
3) Get the current select row from the iterator by passing the newly selected value which you can get from the valueChangeEvent object.

Please find the code snippet below,


        BindingContext bctx = BindingContext.getCurrent();
        oracle.binding.BindingContainer bindings = bctx.getCurrentBindingsEntry();


        DCIteratorBinding iterBind = (DCIteratorBinding)bindings.get("CourseVO1Iterator");
        Row rw = iterBind.getRowAtRangeIndex(((Integer)e.getNewValue()).intValue());

        String courseId= rw.getAttribute("CourseId").toString();
        String courseName= rw.getAttribute("Name").toString();