avinash.moram Posted January 31, 2008 Share Posted January 31, 2008 Hi All, I'm using JRHtmlExporter to display my report pages on browser. Now, in case if generated reports are having hyperlinks, how can i implement them here. here is my code.. if(lFile.equalsIgnoreCase(pReportName)){ Resource lResource = getApplicationContext().getResource(lFile); InputStream lInputStrm = lResource.getInputStream(); jasperPrint = JasperFillManager.fillReport(lInputStrm, pMap, lCon); this is how i fill my report and return the jasperPrint object to the JRHtmlExporter and generate the report as following.. JRHtmlExporter lHtmlViewer = new JRHtmlExporter(); lHtmlViewer.setParameters(lMap); lHtmlViewer.setParameter(JRHtmlExporterParameter.JASPER_PRINT, lResponse.getJasperPrint()); lHtmlViewer.setParameter(JRHtmlExporterParameter.OUTPUT_WRITER, response.getWriter()); lHtmlViewer.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, false); lHtmlViewer.setParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, true); lHtmlViewer.exportReport(); ...And i found an interface in net.sf.jasperreports.engine.JRPrintHyperlink I don't know how useful or how to use this, can somebody help out of this pit.. it would be greatful. Thanks,Avinash. Link to comment Share on other sites More sharing options...
avinash.moram Posted February 4, 2008 Author Share Posted February 4, 2008 Hello All, isn't there anybody who knows how to implement the custom type hyperlink in jasper reports..? Thnx,Avinash. Link to comment Share on other sites More sharing options...
avinash.moram Posted February 4, 2008 Author Share Posted February 4, 2008 Hello All, isn't there anybody who knows how to implement the custom type hyperlink in jasper reports..? Thnx,Avinash. Link to comment Share on other sites More sharing options...
avinash.moram Posted February 4, 2008 Author Share Posted February 4, 2008 Hey All, I have come with an implementation like the following code, As i have to use the methods in JRAbstractExporter and JRPrintHyperlink, i have implemented them in a class and calling that class for generating the report. The code is as follows:Code:import java.util.Map;import net.sf.jasperreports.engine.JRException;import net.sf.jasperreports.engine.JRPrintHyperlink;import net.sf.jasperreports.engine.JRPrintHyperlinkParameter;import net.sf.jasperreports.engine.JRPrintHyperlinkParameters;import net.sf.jasperreports.engine.JasperPrint;import net.sf.jasperreports.engine.base.JRBasePrintHyperlink;import net.sf.jasperreports.engine.export.JRHtmlExporter;import net.sf.jasperreports.engine.export.JRHtmlExporterParameter;public class JRHtmlExporterClass extends JRHtmlExporter { public void export(Map<String, Object> pMap,String pPath, JasperPrint pJP) { String linkType = "ReportExecution"; String hyperlinkReference = "classpath:reports/customer-service-reports/catalogItemReports/catalogItem_by_gameId.jasper"; //Creating the Parameters, these are the parameters which i set in parameters tab of hyperlink option in jasper reports JRPrintHyperlinkParameter lPrintHyperlinkParameter1 = new JRPrintHyperlinkParameter("pGameId",new java.lang.String(),"$F{game_gameId}"«»); //JRPrintHyperlinkParameter lPrintHyperlinkParameter2 = new JRPrintHyperlinkParameter("_report",new java.lang.String(),"classpath:/reports/customer-service-reports/catalogItemReports/catalogItem_by_gameId.jasper"«»); System.out.println("Creating the Parameters=========="«»); // Adding Parameters JRPrintHyperlinkParameters lHyperlinkParameters = new JRPrintHyperlinkParameters(); lHyperlinkParameters.addParameter(lPrintHyperlinkParameter1); //lHyperlinkParameters.addParameter(lPrintHyperlinkParameter2); System.out.println("Adding Parameters========"«»); // setting parameters, hyperlink type and hyperlink target JRPrintHyperlink lHyperlink = new JRBasePrintHyperlink(); lHyperlink.setHyperlinkParameters(lHyperlinkParameters); lHyperlink.setLinkType(linkType); //lHyperlink. setHyperlinkReference(hyperlinkReference); System.out.println("setting parameters, hyperlink type and hyperlink starting"«»); this.startHyperlink(lHyperlink); System.out.println("Starting Hyperlink"«»); this.setHyperlinkProducerFactory(); System.out.println("Setting the hyperlink producer factory"«»); this.setParameters(pMap); this.setParameter(JRHtmlExporterParameter.JASPER_PRINT, pMap.get("JASPER_PRINT"«»)); this.setHyperlinkProducerFactory(); this.setParameter(JRHtmlExporterParameter.OUTPUT_WRITER, pMap.get("OUTPUT_WRITER"«»)); this.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, pMap.get("IS_USING_IMAGES_TO_ALIGN"«»)); this.setParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, pMap.get("IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS"«»)); this.exportReport(); System.out.println("after export report"«»); } I don't why its not displaying any link in my generated report. I am using a custom link type called "ReportExecution", i set that through setLinkType, but everything in vain.. I am in xtream need of this drill down.. So can anybody pull me out of this stuff would be grateful.. Thanks in Adv,Avinash. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now