Thursday, May 17, 2012

Call Oracle Reports From Your ADF Application (Hide Report Parameters From URL)

Hello ADF Developers,

In my previous post http://sameh-nassar.blogspot.com/2010/07/call-oracle-reports-from-your-adf.html I explain a way to call oracle report but this way has a problem. The problem is the report parameters appear in the URL. In this post I will explain another way to call oracle report without displaying report parameters in URL.
to call oracle report follow this steps:
1- Make a new .jsp page (for example the page name is  report.jsp).

2- In faces-config.xml make a navigation rule to report.jsp with outcome "report".

3- Write this code inside the report.jsp page


<%@ page contentType="text/html;charset=utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
</head>
<body onload="document.getElementById('form1').submit();">
<form action="http://serverIp:port/reports/rwservlet" method="post" id="form1">
<c:forEach var="entry" items="${sessionScope.reportMap}">
<input type="hidden" name="${entry.key}" value="${entry.value}" size="100"><br>
</c:forEach>
<input type="hidden" value="username/password@orcl" name="userid" size="100"><br>
</form>
</body>
</html>
view raw report.jsp hosted with ❤ by GitHub




4- Create ADF page (.jspx or .jsf page) then add button (this button will call the report) and in the button action write this code:

    
Map map = new HashMap();
map.put("parameter1", "value");
map.put("parameter2", "value");
map.put("report", "reportName.rdf");// name of the report
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("reportMap", map);
return "report";// report outcome
view raw map.java hosted with ❤ by GitHub