Hi,
We're trying to display a PDF in a pop-up by calling a Servlet within a JSF page by using a task flow in JDeveloper 11g R2.
The relevant JSF snippet:
<af:inlineFrame id="if1" shortDesc="Report" source="/pdfservlet" styleClass="AFStretchWidth"></af:inlineFrame>
The /pdfservlet points to a Servlet with a doGet method as follows:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.reset();
OutputStream out = response.getOutputStream();
FacesContext context = this.getFacesContext(request, response);
OracleReportBean bean =
context.getApplication().evaluateExpressionGet(context, "#{reportBean}", OracleReportBean.class);
bean.run(context, out);
removeFacesContext();
out.close();
}
The Servlet attempts to get the FacesContext, but we've encountered the following exception:
Caused By: javax.faces.FacesException: Cant instantiate class: oracle.adfinternal.view.faces.component.AdfViewRoot.
We removed the following lines from the getFacesContext() method:
UIViewRoot view = facesContext.getApplication().getViewHandler().createView(facesContext, "");
facesContext.setViewRoot(view);
This avoids the exception above, however... We're trying to get the parameters from the form that was submitted. Here is an example element from the form:
<h:inputHidden value="MyMedicationList_Report" id="system_REPORT_RESOURCE"/>
When the Servlet calls the Managed Bean to retrieve the value, it uses:
Map<String, String[]> requestParameters = getRequestParameters();
Parameters p = getParameters();
for( String key : requestParameters.keySet() ) {
for( String value : requestParameters.get( key ) ) {
int i = key.indexOf( ':' );
if( i >= 0 ) {
key = key.substring( i + 1 );
}
p.put( key, value );
}
}
Where getRequestParameters() attempts to get the external context to retrieve the request parameter values map:
return getExternalContext().getRequestParameterValuesMap();
The map comes up empty.
I've tried following http://www.oracle.com/technetwork/developer-tools/adf/learnmore/oct2010-otn-harvest-183714.pdf by setting the web.xml to:
<!-- JspFilter must be configured before adfBindings. -->
<filter-mapping>
<filter-name>JpsFilter</filter-name>
<servlet-name>PDFServlet</servlet-name>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>adfBindings</filter-name>
<servlet-name>PDFServlet</servlet-name>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
And set the data bindings to:
<pageMap>
<page path="/pdfservlet" usageId="ca_bcpra_promis_reporting_view_PDFServletPageDef"/>
</pageMap>
<pageDefinitionUsages>
<page id="ca_bcpra_promis_reporting_view_PDFServletPageDef" path="ca.bcpra.promis.reporting.view.PDFServletPageDef"/>
</pageDefinitionUsages>
The Servlet executes, calls the instantiated managed bean, but cannot read the request parameters.
The button used to launch the task flow in a dialog is:
<af:commandButton text="Run Report" id="submitReport" useWindow="true"
windowEmbedStyle="inlineDocument" windowModalityType="applicationModal" windowHeight="500"
windowWidth="700" action="runReport"/>
By using a task flow, the user inputs are validated before the pop-up is opened. We want to keep that behaviour. The PDF opens and then returns with a NullPointerException:
http://pastebin.com/raw.php?i=PaM64jL4
The Servlet, through the managed bean, makes a request to the report server to pass parameters and generate a PDF. The PDF is streamed back to the browser via the Servlet.
What other approaches can we take to:
1. Send user and system parameters.
2. Generate a PDF on a remote server.
3. Stream the PDF back to the user in a pop-up.
Thank you.