2002 JI Open Discussion Posted August 17, 2006 Share Posted August 17, 2006 By: Bill Fritz - bfritz2 Implementing your own JRHyperLinkListener 2003-01-08 14:42 I have create a report that uses hyperlinkType="RemoteAnchor". When I view the report (using JasperViewer) I would like the referenced report to appear. I know I need to implement my own JRHyperLinkListener to manage this event. However, I would like a liitle more information on what is involved in order to do this. Thanks, Bill By: Teodor Danciu - teodord RE: Implementing your own JRHyperLinkListener 2003-01-09 03:25 Hi, The JRViewer component itself implements this listener interface to respond to your clicks in the JasperViewer. It deals only with some simple types of hyperlink references like the local references. You will have to create your own viewer that uses the JRViewer component, just like the supplied JasperViewer does. Then, you implement this JRHyperlinkListener interface in one of your classes and add an instance of it to the JRViewer component using the addHyperlinkListener() method. You can see this in the "webapp" sample, where the ViewerFrame class represent such a new viewer. You can click on the Google link and it will redirect the browser to that URL. However, only adding the new listener, will not suppress the display of those "recommendations" on the console, but this is something I could fix for you in the next version, so that you don' have to remove the original listener just to get rid of them. I hope this helps. Teodor By: Bill Fritz - bfritz2 RE: Implementing your own JRHyperLinkListener 2003-01-14 06:39 I have followed your advice (thank you by the way) and have everything working. I have another question concerning memory use efficiency. A little background information for the problem will help. I have created a top level report with summary information which has links to individual reports (each with its own set of subreports, etc.). The links are of type hyperlinkType="RemoteAnchor" and they all refer to .jrprint files. I have implemented my own JRHyperLinkListener as you described. Here is a code fragment for that. try { this.pnlMain.remove(viewer); viewer = new JRViewerPlus(hyperlink.getHyperlinkReference(), false); viewer.addHyperlinkListener(this); this.pnlMain.add(viewer, BorderLayout.CENTER); this.pnlMain.revalidate(); } catch (JRException e) { JOptionPane.showMessageDialog(this, e.getMessage()); } My questiion is: Is there a more efficient way of handling this link other than creating a new JRViewerPlus object each time the link event occurs? It is likely that the user will go back and forth from the top level report to these individual reports many times. I looked at the source code, but the methods that I need (in JRViewer) like loadReport are all private and I do not have access to them. Any suggestions would be most appreciated. Thanks, Bill By: Teodor Danciu - teodord RE: Implementing your own JRHyperLinkListener 2003-01-14 07:10 Hi, Make public or protected all the methods or fields you need. Then, if everything is OK, we'll make all these modifications available in the main version of the library. This way I could have some feedback from you in this direction. Thank you, Teodor 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