Sep 15, 2015

Create New database connection or datasource in ireport

Following step is required to create New database connection.

1.) You have to click on Report Datasources.


   Selected Connection/Datasource is shown just beside Report Datasources.



2.) To create New Connection/Datasource click on Report Datasources
     
    


New Dialog Box will be opened which contains all Connections/Datasources Name

3.) Click on New to create new Connection or click on Modify to modify available    Connection/Datasources .

When you will click on New , a new dialog box will open to select Datasource Type.


4.) Select Database JDBC connection to create database Connection and click Next.


5.)Provide Connection name.



6.) Select JDBC Driver from list
   

7.) Now select Oracle Driver from List


      If you have not installed Oracle Driver then Install Oracle Driver.

8.) Now provide JDBC URL ,Username, password and select Save password check box to save the password.


 9.)Now click on Test  to test the connection .


Once you connection test is successful then click on Save to save the Connection.


10.)When you save the connection , Connection will  appear in Connections/Datasources name






Now click on Close to close the dialog box .


Now New Created is set as default connection .

You can create as many as connections but only one will be default at a time.



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


}