Tuesday, March 5, 2013

Displaying alternative values for specific attributes in Oracle ADF

Sometime we come across such type of requirement in Oracle ADF when we want to display some alternative value of attribute based on some condition. For example if we have a column in database that represents status of something, then instead of storing whole word like "Approve", "Reject", "Pending" etc we can just store "A", "R" ,"P" respectively to save space and to improve performance as well. But it is not good to show "A, R , P " etc on UI because it is not user friendly. Alternatively we can show Approve, Reject or pending etc.

  To implement this, go to your ViewrowImpl class, if not created already just create it now. Now go to your desire attribute function and implement it. Below is my code sample.


    "    public String getReqStatus() {
        reqstatus=(String) getAttributeInternal(REQSTATUS);
     
        try{
        if(reqstatus.equalsIgnoreCase("A"))
        return "Approved";
        else if(reqstatus.equalsIgnoreCase("R"))
        return "Rejected";
        else if(reqstatus.equalsIgnoreCase("P"))
        return "Pending";
        else
        return "Not Reviewed";
        }
        catch(Exception Exe)
        {
        System.out.print("Hello Nasir"+Exe);
        }
        return reqstatus;

    }"
I did it for my requisition status. Now on UI you will see the your desire value instead of database specific value. 

0 comments:

Post a Comment