Sep 14, 2015

Installation of oracle database driver in ireport

Following steps are required to install oracle database driver in ireport

1.) Goto Windows Menu bar and click on Services or press Ctrl+5






2.)  Now you will see databases driver listed in service window.



3.) To add database driver right click on Driver folder and click on New Driver.




4.) New window is opened .

    


5.) Click on Add to browse and select ojdbc6.jar jar file save in system.

     In Driver Class section oracle.jdbc.OracleDriver is selected and name as Oracle Thin.




   Now click Ok to finish Installation.

6.) Now you will see Oracle Thin driver has been installed and showing in Driver List.




 

Installation of jasper ireport

Before starting the installation make sure java is installed in your system.

You can download ireport installation file and jar file from jasper community site  ireport setup file.

Double click on installation file.

1.)

The first step introduces the installer and allows you to continue or exit. Click Next.

2.)

 You are prompted to read and accept the license agreement. Read the agreement, agree to the terms by clicking 
 I Agree

3.)
click on Next button to start installation.

4.)


You are prompted for the directory where Jasper ireport is installed referred to as the Jaspersoft  directory. Accept the default or click Browse and select a different location, and click Next.

5.)


Now click on Install button to start Installation.

6.)



wait sometime to complete installation process.
7.)

now click on Finish to finish installation.


Sep 10, 2015

show image from path in oracle adf

I have posted how to upload image in path or in database Blob column Upload Image in server.

Now next is how to show image on Page.

For same we have to use Servlet.

  •  Create Servlet.







  • Now use following below code to in Servlet to show image   
       
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.servlet.*;
import javax.servlet.http.*;

public class ImageShowServlt extends HttpServlet {
    private static final String CONTENT_TYPE = "text/html; charset=UTF-8";

    public void init(ServletConfig config) throws ServletException {
        super.init(config);
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String path = (request.getParameter("path"));


        OutputStream os = response.getOutputStream();
        if (path.equalsIgnoreCase("No")) {
            path = "D:\\Document\\UserImage\\User.jpg";
        }
        if (request.getParameter("path") == "") {
            path = "D:\\Document\\UserImage\\User.jpg";
        }
        InputStream inputStream = null;

        try {

            File outputFile = new File(path);


            inputStream = new FileInputStream(outputFile);
            BufferedInputStream in = new BufferedInputStream(inputStream);
            int b;
            byte[] buffer = new byte[10240];
            while ((b = in.read(buffer, 0, 10240)) != -1) {
                os.write(buffer, 0, b);
            }


        } catch (Exception e) {

            System.out.println(e);
        } finally {
            if (os != null) {
                os.close();
            }
            if (inputStream != null) {
                inputStream.close();
            }

        }
    }
}


  Servlet process image file into bytes and then show image using af:image component.

 Pass image path as HttpServletRequest parameter to Servlet from Managed Bean or binding on page.

  For this create a managed bean with variable name path.

Generate variable Accessor.






Now run application



Feb 21, 2015

Invoke double click action on Table or tree using javascript

To perform double click action on row of  tree or table , we have to use java script .


Drag n drop view object instance as af:tree or af:table from data source on Page















Now drag af:clientListner into tree , add Method name and Type


<af:clientListener method="handleDoubleClick" type="dblClick"/>




















Add af:resource to use javascript method                

<af:resource type="javascript">                   
function handleDoubleClick(evt) {                       
var table = evt.getSource();                       
AdfCustomEvent.queue(table, "DoubleClickEvent", {  }, true);                       
evt.cancel();                   
}                 
</af:resource>

Now to perform server side action  we have to use af:serverListner

So,drag af:serverListner into tree and add Method name and Type 

Method name should java  method in bean class to perform action in java bean class.


<af:serverListener type="DoubleClickEvent"     
method=#{DoubleClickAppBean.DoubleClickOpen}"/> 























public void DoubleClickOpen(ClientEvent clientEvent) {

    \\ Write your code here


}

Oct 25, 2013

IP tracking of Remote address in ADF


To trace IP address of system which is opening page on its web browser following code is used.

      import javax.faces.context.ExternalContext;
      import javax.faces.context.FacesContext;


     FacesContext ctx = FacesContext.getCurrentInstance();

     HttpServletRequest request = (HttpServletRequest)ctx.getExternalContext().getRequest();

     request.getRemoteAddr();

If there is a need to get server IP address then code will be as follows
    
      FacesContext ctx = FacesContext.getCurrentInstance(); 

      HttpServletRequest request = (HttpServletRequest)ctx.getExternalContext().getRequest();

      request.getLocalAddr();