Wednesday, March 6, 2013

Adding and Using Jar files in Oracle ADF Application/Project

In this project i will show how to add and use a Jar file of some other ADF Project in your ADF application. First create a Jar file which you want to use in your ADF application and then add them into your application by using following procedure.

1) In your Oracle ADF application go to "Resource Palette", if not visible then go to view and click on "Resource Palette " and now you will be able to see this.

2) Next do this, select new connection and choose file system.
 3) Now from pop give connection name and choose directory path which contain these jars. Just locate the directory not the jar as shown in below snapshot.
4) Now you will be able to see your Jar file as i can see my Jar file.
5) Now Right click on any Jar file and select add to project as shown below. from popup just choose add jar library.


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. 

Create Sequence in Oracle ADF

In this post i will show how we can create and use sequence in Oracle ADF by using Groovy expression. First create a sequence in your database then use the following code to implement it.
(new oracle.jbo.server.SequenceImpl("PURCHASEREQ_SEQ",adf.object.getDBTransaction())).getSequenceNumber()

here PURCHASEREQ_SEQ is my sequence name that I have created in Database. See the below snapshot for clarification.
so this is really simple and easy way to implement sequence.

Oracle Universal Content Management (UCM) Installation and Configuration guide, Webcenter Content


11)    Required software:  

Ø    Oracle Database 11g.
Ø    Oracle Weblogic server 11g.
Ø    Oracle Repository Creation Utility.
Ø    Oracle Webcenter Content 11g (UCM).
Ø    Oracle JDK

22)    Installation Steps

Ø    Installation of Oracle JDK
Ø    Installation of Oracle Database 11g
Ø    Creation of required schemas for UCM by using Repository Creation Utility (RCU)
Ø    Installation of Oracle Weblogic Server 11g
Ø    Installation of Oracle UCM


3)     Configuration Steps

Ø    Admin server domain creation in weblogic server.
Ø    Domain Creation of UCM managed server in weblogic server.

Friday, March 1, 2013

Delete Multiple records in Oracle ADF Table

In this post i am going to show how to delete multiple records in Oracle ADF table. You can select multiple records and then delete them in one transaction instead of doing one by one.

1) Create a new fusion application and create Employees entity object, then its view object.

2) Create an application module and add your view object in it. you can perform all above step in just one wizard as well.

3) Double click on EmpoyeeVo and go to Java tab as shown in the following snap
4) Click on Edit icon in front of Java classes and then on pop up select "Generate view object class " and "Generate view row class" and click Ok.
5) Now go to your AppModule and double click on it. then go to Java tab and click on edit icon from of Java classes. and from pop up choose " Generate application module class" and click ok
6) Now go to your EmployeeViewImpl class as shown in the following snap.

7) Past the following code in EmployeeViewImpl class


"     public void deleteEmps(List <Key> empKeys )
    {
        if(empKeys!= null)
            {
            for(Key k: empKeys)
            {
                Row[] row = this.findByKey(k, 1);
                if(row!= null && row.length==1)
                {
                    EmployeeVORowImpl r = (EmployeeVORowImpl)row[0];
                    r.remove();
                }
                }
            }
    }"

this is the complete code of EmployeeViewImpl

"package model;

import java.util.List;

import oracle.jbo.Key;
import oracle.jbo.Row;
import oracle.jbo.server.ViewObjectImpl;
// ---------------------------------------------------------------------
// ---    File generated by Oracle ADF Business Components Design Time.
// ---    Fri Mar 01 16:39:55 PKT 2013
// ---    Custom code may be added to this class.
// ---    Warning: Do not modify method signatures of generated methods.
// ---------------------------------------------------------------------
public class EmployeeVoImpl extends ViewObjectImpl {
    /**
     * This is the default constructor (do not remove).
     */
    public EmployeeVoImpl() {
    }
    public void deleteEmps(List <Key> empKeys )
    {
        if(empKeys!= null)
            {
            for(Key k: empKeys)
            {
                Row[] row = this.findByKey(k, 1);
                if(row!= null && row.length==1)
                {
                    EmployeeVoRowImpl r = (EmployeeVoRowImpl)row[0]; //EmployeeVoRowImpl class that //we have create earlier
                    r.remove();
                }
                }
            }
    }
}
"
8) Now go to your view layer and double click on adfc-config.xml for creating and Unbounded task flow.
9) Drag and drop a view component from component palette.
  10) Double click on it and choose defaults from popup and then drag and drop EmployeeView1 data control on page  as a ADF table and make sure you have selected multiple rows from popup as shown in the following snaps.

11) Now from structure window select af:table and then go to advanced properties section and from binding field select down arrow and choose edit.

12) then click new to create new bean give it name delEmps and class name as well other choose default and click ok. Now in front of property click new to create new property in java bean
13) go to your newly created bean and copy past following code in it.

    public List TableKey()
    {
        List<Key> list= new ArrayList<Key>();
        for(Object empKey:empsTable.getSelectedRowKeys())
        empsTable.setRowKey(empKey);
        JUCtrlHierNodeBinding data = (JUCtrlHierNodeBinding)empsTable.getRowData();
        list.add(data.getRow().getKey());
        return list;
        }
following is the my complete code of backing bean


package view;

import java.util.ArrayList;
import java.util.List;

import oracle.adf.view.rich.component.rich.data.RichTable;

import oracle.jbo.Key;
import oracle.jbo.uicli.binding.JUCtrlHierNodeBinding;

public class delEmps {
    private RichTable empsTable;

    public delEmps() {
    }

    public void setEmpsTable(RichTable empsTable) {
        this.empsTable = empsTable;
    }

    public RichTable getEmpsTable() {
        return empsTable;
    }
    public List TableKey()
    {
        List<Key> list= new ArrayList<Key>();
        for(Object empKey:empsTable.getSelectedRowKeys())
        empsTable.setRowKey(empKey);
        JUCtrlHierNodeBinding data = (JUCtrlHierNodeBinding)empsTable.getRowData();
        list.add(data.getRow().getKey());
        return list;
        }
}




14) Now Drag and drop PanelGroup Layout on before af:Table. Look at the below snap
15) Now go to your view object, double click to open it and from java tab, click edit icon in front of client interface and from popup move deleteEmps to right as shown below. It will now appear in your data control.

16) Now go to your jsf page again and then go to data control and drag and drop deleteEmps on PanelGroupLayout and choose ADF button. see below snap.
17) In value field choose expression builder select the method of your bean as shown below
18) then click ok and then go to your jsf page again and after this from data control operation section choose commit function and then drop it on panelGroupLayout as adf button.

19) Now one last thing go to binding from jsf page and form binding section  choose deleteEmps and then click on source tab. the code will be like this

<methodAction id="deleteEmps" RequiresUpdateModel="true" Action="invokeMethod" MethodName="deleteEmps"
                  IsViewObjectMethod="true" DataControl="AppModuleDataControl"
                  InstanceName="data.AppModuleDataControl.EmployeeVo1" IterBinding="EmployeeVo1Iterator">
      <NamedData NDName="empKeys" NDValue="#{delEmps.empsTable}" NDType="java.util.List&lt;oracle.jbo.Key>"/>
    </methodAction>

change it to


<methodAction id="deleteEmps" RequiresUpdateModel="true" Action="invokeMethod" MethodName="deleteEmps"
                  IsViewObjectMethod="true" DataControl="AppModuleDataControl"
                  InstanceName="data.AppModuleDataControl.EmployeeVo1" IterBinding="EmployeeVo1Iterator">
      <NamedData NDName="empKeys" NDValue="#{delEmps.empsTable}" NDType="java.util.List"/>
    </methodAction>

I have just removed &lt;oracle.jbo.Key from about code. save all the code and go to jsf page and run it and test it.