Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Problem with hyperlink in generated html report
locutuz
Hello everybody,
I have the following problem with hyperlinks and bookmarks.
I have a report design that has several areas on the report.
Each area is labelled with a label component (e.g. Area 1, Area 2, etc.)
At the very beginning of the report I wanted to put a navigation list so the user can
navigate to the particular area when clicking on the link.
When I preview the report in the designer, everything works perfect.
But when the report is generated as html file there are no links on the html.
Only the static text remain.
Does anybody have an idea where the problem could be? Every hint is welcome!
The destination of the hyperlink is a bookmark (of a label component) that I named: "bm_Area1"
The hyperlink itself I created by the hyperlink feature. I choose the "Internal bookmark"
option and selected the required bookmark ("bm_Area1") from the drop-down list.
Did I forget somthing important?
Thanks in advance,
Sebastian
Find more posts tagged with
Comments
mwilliams
What is your BIRT version? Also, are you saying that when you run from the designer as HTML, it's not working, but is in the preview? Or it works from the designer, but not if you save the html output and open it later? Please let me know.
locutuz
Hi mwilliams,
thank you for your response.
The BIRT version I use is 3.7.1.
Within the designer the hyperlinks work fine: Preview as well as "Run->View Report->As HTML".
I try to explain the situation where it doesn't work:
I implemented a simple Report-Generation-Tool that I can run from the Windows-command-line.
As input it get an .XML file that's used as the data source.
(The same XML file I use to design the report within the designer.)
The generation tool's output is an html-file. Within this file the hyperlinks do not work.
Even they cannot be identified as a link. (The mouse pointer do not change when hover over them.)
Maybe I do not use the ReportEngine-API correctly?
Below I paste the code of the doGeneration() method of the generation tool.
What do you mean when you say: "..save the html output and open it later." ?
Thanks in advance,
Sebastian
private void doGeneration() {
// ...
// argumtent validation
// ...
designName = args[0];
output = args[1];
xmlDataSource = args[2];
// Create an EngineConfig object.
EngineConfig config = new EngineConfig();
// Explicitly set up the stand-alone application
IPlatformContext context = new PlatformFileContext();
config.setEngineContext(context);
// Set up writing images or charts embedded in HTML output.
HTMLCompleteImageHandler imageHandler = new HTMLCompleteImageHandler();
HTMLEmitterConfig hc = new HTMLEmitterConfig();
hc.setImageHandler(imageHandler);
config.setEmitterConfiguration(RenderOptionBase.OUTPUT_FORMAT_HTML, hc);
ReportEngine engine = null;
try {
// Create the engine.
engine = new ReportEngine(config);
// Accessing a report engine design
IReportRunnable design = null;
design = engine.openReportDesign(designName);
// Create a run and render task object
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
task.setParameterValue("XMLDataSource", xmlDataSource);
// Set the name of an output file
HTMLRenderOption options = new HTMLRenderOption();
options.setImageDirectory("/reportdata");
options.setOutputFileName(output);
// Apply the rendering options to the task
task.setRenderOption(options);
// Instantiate an HTML rendering context
// and set the name of the directory for images
HTMLRenderContext renderContext = new HTMLRenderContext();
renderContext.setImageDirectory("image");
// Apply the rendering context to the task
HashMap<String, HTMLRenderContext> appContext = new HashMap<String, HTMLRenderContext>();
appContext.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT,
renderContext);
task.setAppContext(appContext);
task.run();
} catch (Exception e) {
System.out.println("Error creating report engine. "
+ e.getLocalizedMessage());
System.exit(-1);
} finally {
if (engine != null) {
engine.shutdown();
}
}
}
mwilliams
I was confused to what you were meaning by it works in the designer, but not otherwise. I thought maybe you were saving HTML files and deploying them and then the links weren't working. I see what you're saying now though. At a glance I don't see anything wrong with your code, but I'll take a deeper look and let you know if I see anything. Everything else with the report output from this code works, correct? Just not the hyperlinks? What does the HTML source look like where there is supposed to be a link?
locutuz
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="94279" data-time="1327083930" data-date="20 January 2012 - 11:25 AM"><p>
I was confused to what you were meaning by it works in the designer, but not otherwise. I thought maybe you were saving HTML files and deploying them and then the links weren't working. I see what you're saying now though. At a glance I don't see anything wrong with your code, but I'll take a deeper look and let you know if I see anything. Everything else with the report output from this code works, correct? Just not the hyperlinks? What does the HTML source look like where there is supposed to be a link?<br /></p></blockquote>
<br />
Hi mwilliams, thanks for your reply. Unfortunately I couldn't find a solution until now. To answer your questions: yes, it seems that everything's working fine except the hyperlink-stuff. The attached file is a simple output where a hyperlink to an internal bookmark is set. The bookmark is set to the topic "Provided Stuff" and is named "bm_bookmark1". The link is connected to the label called "go to the bookmark". I choose the internal link "bm_bookmark1" from the drop-down-list of the hyperlink-dialog. The generated HTML-file (the output of my own generating-tool) is attached below.<br />
<br />
I hope you can help me finding the problem.<br />
<br />
Thanks in advance,<br />
<br />
Sebastian
mwilliams
Can you reproduce your error in a report that uses the sample database or another way in which I can run the report, including a java file that will run the report how you're running it? Thanks! If you execute the report using java code from Eclipse, do you have the same issue with the HTML output as you do running your project from the command line?
locutuz
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="94612" data-time="1327442957" data-date="24 January 2012 - 03:09 PM"><p>
Can you reproduce your error in a report that uses the sample database or another way in which I can run the report, including a java file that will run the report how you're running it? Thanks! If you execute the report using java code from Eclipse, do you have the same issue with the HTML output as you do running your project from the command line?<br /></p></blockquote>
<br />
hi mwilliams,<br />
thanks again for your reply.<br />
Yes, I can reproduce the behavior using the sample database instead of the XML data source.<br />
I changed my generator-tool so that it now takes a report-design that is connected to the sample database (see the attachment).<br />
The generator tool takes 2 parameters:<br />
1 - the report.design-file<br />
2 - the output file (HTML file in this case)<br />
<br />
The attached ZIP-file includes the eclipse project of the generator tool (command-line-tool) as well as a simple .rptdesign-file and the output HTML-file I got when I run the generator.<br />
<br />
The report only shows 2 lists: one of the customers, the second of the employees.<br />
It includes 2 hyperlinks:<br />
- the first one is located at the very top of the report named: "go to employees" that shall jump to the employees-list<br />
- the second is located just before the employees-list called: "go to customers"<br />
<br />
In the designer these hyperlinks work fine. But in the generated HTML-file the hyperlinks disappeared and only are shown as static text.<br />
<br />
I hope this helps you reproduce my problem to get me out of this situation :-)<br />
<br />
Thanks in advance!<br />
<br />
Sebastian
mwilliams
It looks like there are some deprecated functions being used. Take a look at this page:
http://www.eclipse.org/birt/phoenix/deploy/reportEngineAPI.php
Like this line in your code: config.setEmitterConfiguration(RenderOptionBase.OUTPUT_FORMAT_HTML, hc);
Now, you set the output format with: options.setOutputFormat("html");
HTMLRenderContext and HTMLRenderConfig are also depracated. So, you might update the code and see if that helps.
locutuz
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="94709" data-time="1327717713" data-date="27 January 2012 - 07:28 PM"><p>
It looks like there are some deprecated functions being used. Take a look at this page:<br />
<br />
<a class='bbc_url' href='
http://www.eclipse.org/birt/phoenix/deploy/reportEngineAPI.php'>http://www.eclipse.org/birt/phoenix/deploy/reportEngineAPI.php</a><br
/>
<br />
<br />
Like this line in your code: config.setEmitterConfiguration(RenderOptionBase.OUTPUT_FORMAT_HTML, hc);<br />
<br />
Now, you set the output format with: options.setOutputFormat("html");<br />
<br />
HTMLRenderContext and HTMLRenderConfig are also depracated. So, you might update the code and see if that helps.<br /></p></blockquote>
<br />
<br />
Hello Michael,<br />
<br />
sorry for my delayed reply.<br />
Now I could test your suggestion to user the EngineOptions instead of the deprecated HTMLEmitterConfig.<br />
I can say that it now works as I expect. Thank you very much for your help! :-)<br />
<br />
Regards,<br />
Sebastian
johnw
IIRC, the EmitterConfigs required handlers for hyperlinks and images that basically would return a string with URIs. The newer method uses a default handler that takes care of all that.
mwilliams
Great to hear! You're very welcome! I'm always glad to help. Let us know whenever you have questions!