Click to See Complete Forum and Search --> : Creating an HTML to pass parameters and access a report


michiems
August 26th, 2004, 03:57 PM
Hi everyone.

I've recently had to learn to use Crystal Reports at work in order to get reports up on a server so that everyone can access them. For those reports that have parameters in them (like Start Date and End Date), Crystal Report creates it's own page in which you have to enter the data in the format Date(yyyy,mm,dd). My boss wants me to make an HTML page from sratch in order to put the logo and allow the user to input the parameters easier. I've already put together the HTML page, but I'm having problems with the javascript and JAVA coding in order to pass the parameters from my HTML page (which is actually a .jsp) to the .jsp that calls the report.

Here is my coding (there are a few things in Spanish...haha sorry):

Report.jsp

<script language="javascript">
function assignparam()
{
var yada1 = "";
var yada2 = "";

yada1 = window.document.submission.fecha1.value;
yada2 = window.document.submission.fecha2.value;

window.location.href="/CantidadRecla.rpt?Fecha1=yada1&Fecha2=yada2"

}
</script>

<HTML>
<HEAD>
<TITLE> Reporte </TITLE>
</HEAD>
<BODY BGCOLOR=WHITE>
<P ALIGN=CENTER><IMG SRC="juanewlogo.jpg">
<H2 ALIGN=CENTER><FONT COLOR=BLACK>Por favor, entre el rango de fecha deseado.</FONT></H2>
<CENTER>
<FORM name="submission" method="post">
<input type="hidden" name="value1">
<input type="hidden" name="value2">
<HR COLOR=BLACK SIZE=5>
<H4 align="center">Fecha Empezando el: <INPUT TYPE="TEXT" name="fecha1" value=""></H4>
<H4 align="center">Fecha Terminando el: <INPUT TYPE="TEXT" name="fecha2" value=""></H4>
<!-- <A IMG SRC="..\crystalreportviewers/images/toolbar/calendar.gif" ALT="Calendar" BORDER=0></A> -->
<HR COLOR=BLACK SIZE=5>
<%
//String fecha1 = window.document.submission.fecha1.value;
//String fecha2 = window.document.submission.fecha2.value;
%>
<p>
<INPUT TYPE="button" VALUE="Ver Reporte" onClick="assignparam();">
</p>
<INPUT TYPE="RESET" VALUE="Limpiar Pantalla">
</FORM>
</center>
</p>
</BODY>
</HTML>

CantidadRecla.jsp (the one that calls the report):

import java.io.File;
import java.util.*;
import java.text.*;

<%@ page import="com.crystaldecisions.report.web.viewer.CrystalReportViewer"%>
<%@ page import="com.crystaldecisions.reports.reportengineinterface.JPEReportSourceFactory" %>
<%@ page import="com.crystaldecisions.sdk.occa.report.reportsource.IReportSourceFactory2" %>
<%@ page import="com.crystaldecisions.sdk.occa.report.reportsource.IReportSource" %>
<%@ page import="com.crystaldecisions.sdk.occa.report.data.*"%>
<%@ page import="com.crystaldecisions.report.web.ServerControl" %>

<%
/*
=================================================================================
SET UP THE REPORT SOURCE
=================================================================================
This sample demonstrates how to view a report with saved data using the Crystal
Reports (v10) Java Reporting Component (JRC) Technology.

- Set the path to the location of the report soruce
- Get the report source
- Place the report source into session and pass it to the viewer
=================================================================================
*/



//Ignore this
if (req.getParameter("Fecha1") != "")
{
response.sendRedirect("http:\\microsoft.com");
}



//Set the location of the report
String path = "/ReportesEstadisticos/CantidadRecla/CantidadRecla.rpt";

//Get the report source
IReportSourceFactory2 rsf = new JPEReportSourceFactory();
IReportSource rptSource = (IReportSource)rsf.createReportSource(path, request.getLocale());

//Place the report into session
session.setAttribute("rptSource", rptSource);

//Redirect to the viewer
response.sendRedirect("viewer.jsp");

%>