Its always a requirement to display a 'Name' for an attribute and insert 'Value' into the DB table. Creating singleOneChoice is made extremely simple in ADF and it shows Display Name to user but stores internal value in database. However when using inputListOfValues or inputComboboxListOfValues it only brings back the value so we cannot search the 'Name'.
Following screenshots show something we dont usually need:


For example in case of HR schema Employees table we need to search & add the manager name but enter managerId into table.


This is how I implemented the solution: DOWNLOAD

  • Create a new update-able transient attribute say ManagerName in the EmployeesView. 




  • Create a new read-only VO to fetch manager name and id




  • Add the manager LOV on ManagerName attribute. Make mappings to return ManagerName and ManagerId. Make List Type as "Input Text with List of Values"




  • Now the important step: In the EmployeesViewRowImpl add the following code to getManagerName() method:   
  •     public String getManagerName() {
            Object mgrId = getAttributeInternal(MANAGERID);
            String managerName = null;
            if(mgrId != null) {
                Object[] obj = {mgrId};
                Key key = new Key(obj);
               
                Row[] rows = getManagersVO1().findByKey(key, 1);
                if(rows != null && rows.length > 0) {
                    managerName = (String)rows[0].getAttribute(1);
                }
            }
            return managerName;
        }
  • The above code basically gets the ManagerName from the Manager LOV for the current ManagerId.
  • Now when we drop the EmployeesView on page it creates a LOV for ManagerName. Set AutoSubmit = true to make show LOV window on tab out.




  • Just for display I have also added ManagerId column on page. Add partialTrigger to point to ManagerName column.
  • Run the page to test the application.




3 comments:

Hi Husain,

Additional post from me on same topic: http://andrejusb.blogspot.com/2009/11/defining-lov-on-reference-attribute-in.html

Regards,
Andrejus

March 23, 2010 at 11:28:00 AM PDT  

http://www.oracle.com/technology/oramag/oracle/09-jan/o19frame.html

March 23, 2010 at 1:59:00 PM PDT  

Good keep it up.

March 29, 2010 at 2:00:00 PM PDT  

Newer Post Older Post Home