Monday, January 5, 2015

Oracle BPM: Display User BPM Tasks Inside ADF Application (Post2)

In my previous post we see how you can display user BPM worklist inside ADF application, but there is one question now, how the bpm worklist know the user which suppose to display his tasks?

You should generate object of IWorkflowContext  using login user information (username and password). To do this follow these steps:

1- In ViewController project add 2 libraries (oracle.bpm.bpm-services.client.jar and oracle.bpm.bpm-services.interface.jar) you can find these jars in (C:\Oracle\Middleware\Oracle_SOA1\soa\modules\oracle.bpm.client_11.1.1)

2- In you ADF application make new class "BPMContextClass.java"


 ////////// BPMContextClass.java ////////////

import java.util.HashMap;
import java.util.Map;
import oracle.bpel.services.bpm.common.IBPMContext;
import oracle.bpel.services.workflow.client.IWorkflowServiceClient;
import oracle.bpel.services.workflow.client.IWorkflowServiceClientConstants;
import oracle.bpel.services.workflow.client.WorkflowServiceClientFactory;
import oracle.bpm.client.BPMServiceClientFactory;
import oracle.bpm.services.client.IBPMServiceClient;

public class BPMContextClass
{
  private static String url = "t3://localhost:7001"; // BPM serverIp:port

  public static BPMServiceClientFactory getBPMServiceClientFactory()
  {
    Map properties = new HashMap();
    properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.CLIENT_TYPE, WorkflowServiceClientFactory.REMOTE_CLIENT);
    properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_PROVIDER_URL, url);
    properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    return BPMServiceClientFactory.getInstance(properties, null, null);
  }

  public static IBPMContext getIBPMContext(String username, String password) throws Exception
  {
    return getBPMServiceClientFactory().getBPMUserAuthenticationService().authenticate(username, password.toCharArray(), null);
  }

  public static IWorkflowServiceClient getIWorkflowServiceClient()
  {
    return getBPMServiceClientFactory().getWorkflowServiceClient();
  }

  public static IBPMServiceClient getBPMServiceClient()
  {
    return getBPMServiceClientFactory().getBPMServiceClient();
  }
}

/////////End BPMContextClass.java///////

3- Follow the previous post to make page display user worklist (e.x. userTasks.jspx).

4- From faces-config.xml make new global navigation rule and set  userTasks.jspx "From Outcome" to "userTasks"


5- Make new login page (login.jspx) as shown


6- In the login button action write this code

  public String loginAction()
  {
    FacesContext ctx = FacesContext.getCurrentInstance();
    HttpServletRequest request = (HttpServletRequest)ctx.getExternalContext().getRequest();
    String usernameValue = null;
    try
    {
      usernameValue = usernameInputText.getValue().toString();
      String passwordValue = passwordInputText.getValue().toString();
      Subject subject = Authentication.login(new URLCallbackHandler(usernameValue, passwordValue));
      weblogic.servlet.security.ServletAuthentication.runAs(subject, request);
      IWorkflowContext workflowContext = initBPMContext(usernameValue, passwordValue);
      setManagedBeanValue("sessionScope.workflowContext", workflowContext);
      IBPMContext ibpmContext = BPMContextClass.getIBPMContext(usernameValue, passwordValue);
      setManagedBeanValue("sessionScope.ibpmContext", ibpmContext);
    }
    catch (Exception e)
    {
      // TODO: Add catch code
      e.printStackTrace();
      return null;
    }
 
    return "userTasks";
  }

8- In the login backbean write this code (this code will be used by login button action "loginAction()")

  public IWorkflowContext initBPMContext(String userName, String password) throws WorkflowException
  {
    IWorkflowServiceClient wfSvcClient = WorkflowServiceClientFactory.getWorkflowServiceClient(WorkflowServiceClientFactory.REMOTE_CLIENT);
    ITaskQueryService querySvc = wfSvcClient.getTaskQueryService();
    IWorkflowContext ctx = querySvc.authenticate(userName, password.toCharArray(), null);
    return ctx;
  }

  public void setManagedBeanValue(String beanName, Object newValue)
  {
    StringBuffer buff = new StringBuffer("#{");
    buff.append(beanName);
    buff.append("}");
    setExpressionValue(buff.toString(), newValue);
  }

  public void setExpressionValue(String expression, Object newValue)
  {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Application app = facesContext.getApplication();
    ExpressionFactory elFactory = app.getExpressionFactory();
    ELContext elContext = facesContext.getELContext();
    ValueExpression valueExp = elFactory.createValueExpression(elContext, expression, Object.class);
    Class bindClass = valueExp.getType(elContext);
    if (bindClass.isPrimitive() || bindClass.isInstance(newValue))
    {
      valueExp.setValue(elContext, newValue);
    }
  }



7- deploy the application to SOA server and after login you will find user worklist.



You can download the sample application from here.

Tuesday, December 30, 2014

Oracle BPM: Display User BPM Tasks Inside ADF Application (Post 1)

If you need to display Oracle BPM worklist inside ADF page follow these steps:

1- Be sure ADF application is developed by JDev 11g R1.
2- In ADF project go to project properties --> Libraries and Classpath and add these libraries:

  * bpm-services.jar (\Middleware\jdeveloper\soa\modules\oracle.soa.workflow_11.1.1)
  * adflibTaskListTaskFlow.jar (\Middleware\jdeveloper\soa\modules\oracle.soa.worklist_11.1.1)
  * adflibWorklistComponents.jar (\Middleware\jdeveloper\soa\modules\oracle.soa.worklist_11.1.1)

  * WSRP Container
  * BPM Worklist Components
  * BPM Services





3- Make new .jspx page and from component palette select adflibTaskListTaskFlow.jar -->Regions.
4- Drag taskList-task-flow-definition from component palette and drop it in the .jspx page as region


5- From task flow parameters set these 2 parameters




6- In ADF application Add new deployment Descriptor weblogic-application.xml (in ADF project right click ---> new --> Deployment Descriptor -->  Weblogic Deployment Descriptor


7- From opening dialog select weblogic-application.xml


8- Open weblogic-application.xml and write 

    oracle.soa.workflow


9- Now you can run ADF application and after user login you have to generate IWorkflowContext with  username and password and the user will see his tasks. (In next post i will explain how to   generate IWorkflowContext).

Thursday, October 23, 2014

Dealing With Dates in Java

Many developers sometimes face a problems when they dealing with dates. In java there are many types of dates as:

- java.util.Date
- java.sql.Date
- java.sql.Timestamp
- oracle.jbo.domain.Date
- oracle.jbo.domain.Timestamp

ADF developers sometimes need to:

- Get current date (oracle.jbo.domain.Date or  oracle.jbo.domain.Timestamp) to set attribute in ViewObject programmatically .

- Convert between dates types.

- Add/Subtract some days from date.

- Display current date on the screen (as string) in specific format.

- Display name of current day in this week (Saturday - Sunday - ...... - Friday).

- Get current time.

- Get current day.

- Get current month.

- Get current year.

- Compare between two dates.

- Get the number of days difference between two dates.

All these previous functions developers need to know so, I made a set of functions to help developers to deal with dates.

  /** function return current date time in format (dd / MM / yyyy - HH:mm:ss) */
  public static String getDisplayedDateTime()
  {
    Calendar cal = Calendar.getInstance();
    String dateFormat = "dd / MM / yyyy - HH:mm:ss";
    SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
    return sdf.format(cal.getTime());
  }

  /** function return current date or time depending on the format which you are want. Just send a format and the function will return the current date or time depending on the 
      format which you are sent (e.g. getDisplayedDateFormat("yyyy-mm-dd") it will return 2013-11-18 */
  public static String getDisplayedDateFormat(String dateFormat)
  {
    Calendar cal = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
    return sdf.format(cal.getTime());
  }

  /** function return the index of current day in this week (if today is Sunday it will retun 1 and if the today is Monday this function will return 2 and so on... 
      till Saturday it will return 7) */
  public static int getCurrentDayOfWeek()
  {
    Calendar cal = Calendar.getInstance();
    return cal.get(Calendar.DAY_OF_WEEK);
  }

  /** function return the name of current day in this week (Saturday - Sunday - ...... - Friday) */
  public static String getCurrentDayOfWeekName()
  {
    int numberOfDay = getCurrentDayOfWeek();
    if(numberOfDay == 7)
    {
      return "Saturday";
    }
    else if(numberOfDay == 1)
    {
      return "Sunday";
    }
    else if(numberOfDay == 2)
    {
      return "Monday";
    }
    else if(numberOfDay == 3)
    {
      return "Tuesday";
    }
    else if(numberOfDay == 4)
    {
      return "Wednesday";
    }
    else if(numberOfDay == 5)
    {
      return "Thursday";
    }
    return "Friday";
  }

  /** function return current day. ( e.g. today is 2013/11/18 this function will return 18) */
  public static int getCurrentDay()
  {
    Calendar cal = Calendar.getInstance();
    return cal.get(Calendar.DAY_OF_MONTH);
  }

  /** function return current month. ( e.g. today is 2013/11/18 this function will return 11) */
  public static int getCurrentMonth()
  {
    Calendar cal = Calendar.getInstance();
    return cal.get(Calendar.MONTH) + 1;
  }

  /** function return current year. ( e.g. today is 2013/11/18 this function will return 2013) */
  public static int getCurrentYear()
  {
    Calendar cal = Calendar.getInstance();
    return cal.get(Calendar.YEAR);
  }

  /** function will return current date as an oracle Date object */
  public static oracle.jbo.domain.Date getCurrentOracleDate()
  {
    return new oracle.jbo.domain.Date(oracle.jbo.domain.Date.getCurrentDate());
  }

  /** function will return current date and time as an oracle Date object */
  public static oracle.jbo.domain.Date getCurrentOracleDateTime()
  {
    return new oracle.jbo.domain.Date(new java.sql.Timestamp(System.currentTimeMillis()));
  }

  /** function will return current date and time as an oracle Timestamp object */
  public static oracle.jbo.domain.Timestamp getCurrentOracleTimestampDateTime()
  {
    return new oracle.jbo.domain.Timestamp(new java.util.Date().getTime());
  }

  /** function will return current time */
  public static String getCurrentTime()
  {
    return  getDisplayedDateFormat("HH:mm");
  }

  /** function receive oracle date and return true or false (if sent date greater than current date it will return true 
      but if sent date less than or equal current date it will return false */
  public static boolean isDateGreaterThanCurrentDate(oracle.jbo.domain.Date d)
  {
    if(d == null)
      return false;
 
    oracle.jbo.domain.Date currentDate = new oracle.jbo.domain.Date(oracle.jbo.domain.Date.getCurrentDate());
    if(d.compareTo(currentDate) > 0)
      return true;
 
    return false;
  }

  /** function receive two oracle dates and return true or false (if first date greater than second date it will return true 
      but if first date less than or equal second date it will return false */
  public static boolean isFirstDateGreaterThanSecondDate(oracle.jbo.domain.Date d1, oracle.jbo.domain.Date d2)
  {
    if(d1 == null && d2 == null)
      return false;
 
    if(d1 == null && d2 != null)
      return false;
 
    if(d1 != null && d2 == null)
      return true;
 
    if(d1.compareTo(d2) > 0)
      return true;
 
    return false;
  }

  /** function receive three oracle dates and return true or false (if first date greater than or equal second date and first date less than or equal third date it will return true. 
      otherwise it will return false */
  public static boolean isFirstDateBetweenTwoDates(oracle.jbo.domain.Date d1, oracle.jbo.domain.Date d2, oracle.jbo.domain.Date d3)
  {
    if(d1 == null || d2 == null || d3 == null)
      return false;
 
    if(d1.compareTo(d2) >= 0 && d1.compareTo(d3) <= 0)
      return true;
 
    return false;
  }

  /** function receive date and integer then add the integer to the date then return the result date.
      (e.g. if you send 2013/07/13 and 5 to this function the function will return 2013/07/18 */
  public static Date addDayToOracleDate(oracle.jbo.domain.Date date, int days)
  {
    if (date != null)
    {
      Calendar c1 = Calendar.getInstance();
      c1.setTime(date.getValue());
      c1.add(Calendar.DATE, days);
      java.util.Date javaUtilDate = c1.getTime();
      long javaMilliseconds = javaUtilDate.getTime();
      java.sql.Date javaSqlDate = new java.sql.Date(javaMilliseconds);
      return new oracle.jbo.domain.Date(javaSqlDate);
    }
    return null;
  }

  /** function receive two oracle dates then return the number of days difference between them. (e.g. if you send 2013/07/20 , 2013/07/13 to the function the function will return 7 */
  public static long getDifferenceDaysBetweenTwoDates(oracle.jbo.domain.Date d1, oracle.jbo.domain.Date d2)
  {
    if(d1 != null && d2 != null)
    {
      return (d1.getValue().getTime() - d2.getValue().getTime())/(24 * 60 * 60 * 1000);
    }
    return 0;
  }

  /** function receive oracle date and convert it to java.util date then return java.util date */
  public static java.util.Date convertOracleDateToJavaUtilDate(oracle.jbo.domain.Date oracleDate)
  {
    if(oracleDate == null)
      return null;
 
    java.sql.Date javaSqlDate = oracleDate.dateValue();
    long javaMilliSeconds = javaSqlDate.getTime();
    return new java.util.Date(javaMilliSeconds);
  }

  /** function receive oracle date and convert it to java.sql date then return java.sql date */
  public static java.sql.Date convertOracleDateToJavaSqlDate(oracle.jbo.domain.Date oracleDate)
  {
    if(oracleDate == null)
      return null;
 
    return oracleDate.dateValue();
  }

  /** function receive java.util date and convert it to oracle date then return oracle date */
  public static Date convertJavaUtilDateToOracleDate(java.util.Date javaUtilDate)
  {
    if(javaUtilDate == null)
      return null;
 
    long javaMilliseconds = javaUtilDate.getTime();
    java.sql.Date javaSqlDate = new java.sql.Date(javaMilliseconds);
    return new oracle.jbo.domain.Date(javaSqlDate);
  }

  /** function receive java.sql date and convert it to oracle date then return oracle date */
  public static Date convertJavaSqlDateToOracleDate(java.sql.Date javaSqlDate)
  {
    if(javaSqlDate == null)
      return null;
 
    return new oracle.jbo.domain.Date(javaSqlDate);
  }

  /** function receive java.util date and convert it to java.sql date then return java.sql date */
  public static java.sql.Date convertJavaUtilDateToJavaSqlDate(java.util.Date javaUtilDate)
  {
    if(javaUtilDate == null)
      return null;
 
    long javaMilliseconds = javaUtilDate.getTime();
    return new java.sql.Date(javaMilliseconds);
  }

  /** function receive java.sql date and convert it to java.util date then return java.util date */
  public static java.util.Date convertJavaSqlDateToJavaUtilDate(java.sql.Date javaSqlDate)
  {
    if(javaSqlDate == null)
      return null;
 
    long javaMilliseconds = javaSqlDate.getTime();
    return new java.util.Date(javaMilliseconds);
  }

Thursday, June 5, 2014

Deploy ADF Application Using Side-by-Side Deployment

This technique is used for deploying applications with versions. In first time you deploy application it will take version1. If you make some changes of that application and you want to re-deploy it again, side-by-side deployment manage you to re-deploy application without losing the connection to the application.
assume you deploy application with version1 and some of user connect to the application and you want to redeploy the application with version2, the connection user still connect to version1 but every user close the connection and reconnect to the application again it will connect to the version2.
After all user connect to version2 and no one connect to version1 the application of version1 status will become "Retail" at this moment you can delete version1.

Note : 
- Side-by side deployment allow you to make only two versions. It means you should delete old version before you make new version.(for example: you deploy application with version1 and you redeploy it with version2, if you want to redeploy it with version3 you should first delete version1).

- Deploying application will done from command prompt not from console.

To deploy ADF Application:
1- Open cmd and go to the admin domain folder and set domain environment as shown


   2-.     write this (you should changes the bold words )
D:\Oracle\Middleware\user_projects\domains\modamoDomain>java weblogic.Deployer -adminurl t3://localhost:7001 -user weblogic -password weblogic1 -deploy -name myEar -source D:\Deploy\myEar.ear -targets MyServer -stage -appversion 1.0


localhost:7001 ---> admin domain address and admin domain port
weblogic ---> username of the admin weblogic server
weblogic1 ---> password of the admin weblogic server
myEar ---> name of the application which will display in the console.
D:\Deploy\ttEar.ear --> location of the ear file (you should write the full path of the location of the ear).
MyServer ---> Name of the server which you will deploy the application in. if you want to deploy the application in the cluster type the name of the cluster.
1.0 ---> version number of the application which will appear beside the application on the console.


Now you can open the console and you will find your application deployed.

To re-deploy the application:
1- Open cmd and go to the admin domain folder and set domain environment as in picture



2-  write this (you should changes the bold words )
java weblogic.Deployer -adminurl t3://localhost:7001 -user weblogic -password weblogic1 -redeploy -name myEar -source D:\Deploy\myEar.ear -targets MyServer -appversion 1.1


Wednesday, May 7, 2014

Apply SSL (Https) To Weblogic Managed Server

This post will help you to apply ssl (https) protocol to managed server, I made a document explain how to do that.

you can download this document from this link

http://www.mediafire.com/view/9i4xc0ag5k1474a/ApplySSL.doc

Wednesday, April 23, 2014

Deploy ADF Application To Glassfish (Step-by-Step)

In this post I will explain how you can deploy ADF Application to Glassfish server.

I made a document file explain this in easy way (Step by Step) you can download this file from this link

http://www.mediafire.com/view/riy5xt56cga0yh0/Deploy_ADF_Application_To_Glassfish.doc

Tuesday, April 22, 2014

Apply Patches To Weblogic (Step-by-Step)

If you want to deploy ADF Application developed using JDeveloper 11.1.2.x.x you should apply patches to the weblogic (10.3.6).

after applying patches to weblogic (10.3.6) you can deploy any ADF Application (11.1.1.x.x or 11.1.2.x.x).

I uploaded a documentations step by step to do that.

http://www.mediafire.com/view/sdugiufsc9wv79a/Apply_Patches_To_Weblogic.doc


You can download Patches from

http://www.mediafire.com/download/j17e214j0b4rnfr/WLPatchesFor2.3.rar

this patches suitable for applications developed using JDeveloper 11.1.2.3.0 or JDeveloper 11.1.2.4.0

Setup and configure weblogic environment (Step-by-Step)

In this post I will explain how to setup and configure weblogic for deploying ADF Applications. I made a documentation explain how to setup and configure weblogic in easy way step by step.

You can download this document from this URL:

http://www.mediafire.com/view/nozijs14a9cst1e/Steps_to_Establish_Weblogic_Environment.doc

Note :After you finish weblogic setup and configuration you can deploy only ADF Applications which is developed using JDeveloper 11.1.1.x.x.

If you want to deploy ADF Applications developed using JDeveloper 11.1.2.x.x. you should apply patches to the weblogic.

To know how to apply batches to weblogic refer to this post

http://sameh-nassar.blogspot.ie/2014/04/apply-patches-to-weblogic.html




Tuesday, December 3, 2013

Easy Way To Clear ADF Table Columns Filters

In ADF table you can enable column filters just when you drag viewobject to the page and choose Table --> ADF Table
Just select Enable Filtering
Now when you run the page you will find inputtext above every cloumn in the table
You can filter the data using these inputtext above every cloumn. If you want to clear all the filters inputtext just add new cloumn to the table (put it as a first column)




 Select the new cloumn and from Property Inspector (Appearance section) set Width to "14" and RowHeader to "true"

Now run the page again you will find new icon above first column when you press this icon it will clear all columns filters and re-execute the view object query.








Sunday, December 9, 2012

Using Jasper Report In ADF Application (Step-by-Step)

In my previous post  http://sameh-nassar.blogspot.com/2009/10/using-jasper-reports-with-jdeveloper.html I explain how to use Jasper Report but because of many people send me many requests for explain this topic in more detail so I will explain it in step by step.

our example will make application with one screen this screen has a table of employees you should select an employee and send the selected employee id to jasper report to print the selected employee data.

Before we begin be sure of:

1- You download iReport-4.0.1 (you can get it from http://sourceforge.net/projects/ireport/files/iReport/iReport-4.0.1/) I download iReport-4.0.1-windows-installer.exe.

2- You have database has hr schema.

3- Setup JDeveloper 11g (any release).

Now we can begin ......

Step 1:

Setup iReport-4.0.1
Step 2:
Open JDeveloper and make new ADF Application (name it for example JasperApplication)

Step 3:

Connect your application to your database HR Schema by right click in your Model application ---> new ---> ADF Business Components ---> Business Components From Table
Add your connection and test the connection

Add one Entity Objects (Employees)
Add one Updatable View Objects
Then press finish, your application should be like this
Step 4:
Create new jspx page (name it for example employees.jspx)
In your ViewController project right click on Web Content folder then new --->JSF ---> JSF Page

From the Data Controls drag EmployeesView1 to your page as an ADF Read-only Table


From Row Selection Select Single Row
Add a button above a table (text it for example Run Report) and its action point to a method in a back bean (for example Back bean name is JasperBean.java)


To get the selected employee id:
    DCIteratorBinding empIter = (DCIteratorBinding) getBindings().get("EmployeesView1Iterator");
    String empId = empIter.getCurrentRow().getAttribute("EmployeeId").toString();

where EmployeesView1Iterator is the iterator name in the page definition and EmployeeId is the attribute name in the EmployeesView.

now we should pass the selected employee Id to jasper report so, you should make a map and set the parameter like
    Map m = new HashMap();
    m.put("employeeId", empId);// employeeId is a jasper parameter name

then you should call the jasper report like this method
 runReport("empReport.jasper", m);

where runReport is the method take jasper report name (empReport.jasper) and the map which hold the parameter

write this code in your JasperBean.java

--------------------------------------------------------------------------------------------------------------
  public BindingContainer getBindings()
  {
    return BindingContext.getCurrent().getCurrentBindingsEntry();
  }
  public Connection getDataSourceConnection(String dataSourceName)
      throws Exception
    {
      Context ctx = new InitialContext();
      DataSource ds = (DataSource)ctx.lookup(dataSourceName);
      return ds.getConnection();
    }
 
  private Connection getConnection() throws Exception
  {
    return getDataSourceConnection("hrDS");// use datasourse in your application
  }
 
  public  ServletContext getContext()
    {
      return (ServletContext)getFacesContext().getExternalContext().getContext();
    }
  public  HttpServletResponse getResponse()
    {
      return (HttpServletResponse)getFacesContext().getExternalContext().getResponse();
    }
  public static FacesContext getFacesContext()
    {
      return FacesContext.getCurrentInstance();
    }
  public void runReport(String repPath, java.util.Map param) throws Exception
  {
    Connection conn = null;
    try
    {
      HttpServletResponse response = getResponse();
      ServletOutputStream out = response.getOutputStream();
      response.setHeader("Cache-Control", "max-age=0");
      response.setContentType("application/pdf");
      ServletContext context = getContext();
      InputStream fs = context.getResourceAsStream("/reports/" + repPath);//we will put the report under folder "reports" under Web Content
      JasperReport template = (JasperReport) JRLoader.loadObject(fs);
      template.setWhenNoDataType(WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL);
      conn = getConnection();
      JasperPrint print = JasperFillManager.fillReport(template, param, conn);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      JasperExportManager.exportReportToPdfStream(print, baos);
      out.write(baos.toByteArray());
      out.flush();
      out.close();
      FacesContext.getCurrentInstance().responseComplete();
    }
    catch (Exception jex)
    {
      jex.printStackTrace();
    }
    finally
    {   
      close(conn);
    }
  }
 
  public void close(Connection con)
   {
     if (con != null)
     {
       try
       {
         con.close();
       }
       catch (Exception e)
       {
       }
     }
   }
--------------------------------------------------------------------------------------------------------

After you write this code you will find Jasper library missing

to get jasper libraries goto the folder which you setup iReport for example in this path
C:\Program Files (x86)\Jaspersoft\iReport-4.0.1\ireport\modules\ext
and get these libraries:
1- iText-2.1.7.jar
2- jasperreports-4.0.1.jar
3- jasperreports-fonts-4.0.1.jar

add this libraries to your ViewController project ---> Right click on the project ---> Project Properties--->Libraries And Classpath ---> Add JAR/Directory

Now your code should have no error

Now my Back bean code is :
----------------------------------------------------------------------------------------------------------------------
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.ServletContext;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.type.WhenNoDataTypeEnum;
import net.sf.jasperreports.engine.util.JRLoader;
import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.binding.BindingContainer;

public class JasperBean
{
  public JasperBean()
  {
  }

  public String runReportAction()
  {
    DCIteratorBinding empIter = (DCIteratorBinding) getBindings().get("EmployeesView1Iterator");
    String empId = empIter.getCurrentRow().getAttribute("EmployeeId").toString();
    Map m = new HashMap();
    m.put("employeeId", empId);// where employeeId is a jasper report parameter
    try
    {
      runReport("empReport.jasper", m);
    }
    catch (Exception e)
    {
    }
    return null;
  }

  public BindingContainer getBindings()
  {
    return BindingContext.getCurrent().getCurrentBindingsEntry();
  }
 
  public Connection getDataSourceConnection(String dataSourceName)
      throws Exception
    {
      Context ctx = new InitialContext();
      DataSource ds = (DataSource)ctx.lookup(dataSourceName);
      return ds.getConnection();
    }
 
  private Connection getConnection() throws Exception
  {
    return getDataSourceConnection("hrDS");// datasource name should be defined in weblogic
  }
 
  public  ServletContext getContext()
    {
      return (ServletContext)getFacesContext().getExternalContext().getContext();
    }
  public  HttpServletResponse getResponse()
    {
      return (HttpServletResponse)getFacesContext().getExternalContext().getResponse();
    }
  public static FacesContext getFacesContext()
    {
      return FacesContext.getCurrentInstance();
    }
  public void runReport(String repPath, java.util.Map param) throws Exception
  {
    Connection conn = null;
    try
    {
      HttpServletResponse response = getResponse();
      ServletOutputStream out = response.getOutputStream();
      response.setHeader("Cache-Control", "max-age=0");
      response.setContentType("application/pdf");
      ServletContext context = getContext();
      InputStream fs = context.getResourceAsStream("/reports/" + repPath);
      JasperReport template = (JasperReport) JRLoader.loadObject(fs);
      template.setWhenNoDataType(WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL);
      conn = getConnection();
      JasperPrint print = JasperFillManager.fillReport(template, param, conn);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      JasperExportManager.exportReportToPdfStream(print, baos);
      out.write(baos.toByteArray());
      out.flush();
      out.close();
      FacesContext.getCurrentInstance().responseComplete();
    }
    catch (Exception jex)
    {
      jex.printStackTrace();
    }
    finally
    {   
      close(conn);
    }
  }
 
  public void close(Connection con)
   {
     if (con != null)
     {
       try
       {
         con.close();
       }
       catch (Exception e)
       {
       }
     }
   }
}
--------------------------------------------------------------------------------------------------------------------------
Now depending on my previous code we should make a report the name of this report should be "empReport" and has one parameter "employeeId"

Step 5:

Open iReport and make a connection to hr database but first ..... iReport has not oracle database driver so you use oracle database you should first add a ojdbc jar file to the classpath of iReport.

you can get ojdbc jar file in your middleware home like:
C:\Oracle\Middleware\wlserver_10.3\server\lib and search for ojdbc6.jar

In iReport goto Tools---> Options ---> Classpath and add ojdbc6.jar
Now make a new connection to hr schema
Now from File ---> New and make new Report
Choose any template or make it blank then press "Launch Report Wizard"

Write report name "empReport" and under your web content folder in ViewController project make new folder "reports" and save the report on this path


Press on Design query button and select your schema then drag Employees table
then press Ok you will find the report query will generated then press Next and shuttle the field you want to displayed in your report
Then press next then finish. You will find you report generated.
Goto the report query as shown:

and make new Parameter "employeeId"
add where clause to the query like:
WHERE EMPLOYEES."EMPLOYEE_ID"=to_number($P{employeeId})

Now you can preview your report by pressing on "Preview" button and enter for example employeeId = 200


Now compile your report to generate .jasper file in your application
If you goto your application you should something like this:
before you run be sure of two things:
1- any picture you use in jasper should be in the class path
2- You should define datasource in your weblogic "as we write in the code datasource is hrDS"


for how you can define data source in weblogic try this http://www.mediafire.com/view/?g7odbc06rpad1aa

Step 6:
run your application and select any employee then press on "Run Report" button
for example select employee Id= 104 then run report



you can download the application from this link JasperApplication