Jasper Report Input Page Customization
Objective
You want to provide a parameter input page for the Jasper reports in your Windchill Business Reporting (WBR) system.
Background
The Windchill Business Reporting (WBR) solution supports reports with parameters. Windchill viewers can provide a basic input page that is presented to users to gather parameter values when the report is executed. Often times this input page requires customization for a better end user experience. For customizing input pages, use a standard Windchill Java Server Page (JSP) functionality.
Scope/Applicability/Assumptions
This documentation explains how to author a custom JSP for Jasper reports.
Assume you have access to the Windchill server JSP directory, <WindchillHome>/codebase/wtcore/jsp, to create the JSP input page <MyInputPage> in its associated sub-directory <MyInputPagePackage>.
Assume you have access rights to edit an existing Windchill Report object, <MyReport> in the Site context.
Solution
Construct and specify a custom input page for reports.
Procedure – Specifying Optional Parameters
Customization Points
Jasper reports that use Windchill Data Sources require every parameter value to be specified. However, a report can be more useful, if the user can optionally leave parameter values unspecified and the report ignores the related criteria or implicitly uses a suitable default. To achieve this behavior, it is possible to pass a parameter value consisting of a single space (“ “) and by making a single space the default value for the parameter in you input page, the user will not be required to enter anything into the parameter input field. When using this technique, you must ensure that the underlying Data Source will be able to properly handle the empty space values that are passed.
Procedure – Specifying Parameters To Omit
By default, only the Data Source parameters are included in the Jasper request from Windchill. However, parameters can be explicitly excluded using the "parametersToOmit" request attribute. Note, this is a servlet request object attribute list. Assume you want to omit the parameter with name, “param1” that is in the list of parameters for the report’s Data Source. The following is an example for specifying this.
<%
request.setAttribute("parametersToOmit",
Arrays.asList("param1"));
%>
Limitations
None.
Sample Code
<%@page contentType="text/html"%><%@page pageEncoding="UTF-8"%>
<%@page import="java.net.URL"%>
<%@page import="com.ptc.windchill.enterprise.report.ReportHelper"%>
<%!private static void executeReport(final HttpServletRequest request, final
HttpServletResponse response, String reportName) throws Exception {
System.out.println("DemoInputPage.jsp:executeReport() :" + reportName);
if(request.getParameter("username") == null) {
throw new Exception("Authentication Needed");
}
response.sendRedirect("/");
}
%>
<%
String state = request.getParameter("PartReportTemplate_stateParameter");
if(state!=null)
{
try {
executeReport(request, response, "DemoReport");
}catch (Exception e) {
e.printStackTrace();
}
}%>

<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Demo input page</title>
</head>
<body>
<form action="#" name="mainform" id="mainform" method="post" >
<br>
<center>
<h1>
Demo Input JSP for Report
</h1>
</center>
<br>
<br>
<br>
<h2> Parameter for PartReportTemplate</h2>
<hr/>
<table frame="box">
<th>Parameter Name</th>
<th>Parameter Value</th>
<tr>
<td>State(upper case e,g APPROVED)</td>
<td><input type="text" name="PartReportTemplate_stateParameter" /></td>
</tr>
</table>
<input type=hidden name="USER" id ="USER" value="<%=state %>">
<button type="submit">Generate Report</button>
</form>
</body>
</html>
Examples of Usage in Windchill Code
All of the out-of-the-box reports use Windchill JSP input pages.
War dies hilfreich?