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();

No comments:

Post a Comment