onRender method
Hi,
I have recently upgraded BIRT from version 2.2.1.1 to 2.6.2. Now it seems that the onRender method has stopped working or changed its behaviour. I used it to print a text on a continuing page, a text I don't want on the first page.
Does anyone know anything about this?
/aca
I have recently upgraded BIRT from version 2.2.1.1 to 2.6.2. Now it seems that the onRender method has stopped working or changed its behaviour. I used it to print a text on a continuing page, a text I don't want on the first page.
Does anyone know anything about this?
/aca
0
Comments
-
I am updating a report that has a boolean variable that is set to true/false depending on if it is a single page or multiple page printout. If multiple then a text "continuing" is to be printed on the second, third and so on page of the report. The actual update I'm doing is to correct the font sizes as they have changed in the upgrade from 2.2.1.1 to 2.6.2. When I tested this however I also found out that the "continuing" text is no longer printed.
The xml source looks like this:
// THIS IS FOUND AT THE TOP OF THE REPORT, BEFORE LISTING THE THEME PROPERTY ETC.
<method name="initialize"><![CDATA[// This variable could be used to mark when a table is being rendered
// The header/footer can then add extra elements, like "Continue on the next page".
var renderingTable = false;]]></method>
...
...
...
<row id="2845">
<property name="height">0.187in</property>
<property name="style">borderBottomLine</property>
<list-property name="visibility">
<structure>
<property name="format">all</property>
////IN THE PAGE HEADER IS THE CONTROL IF THE TEXT IS TO BE PRINTED
<expression name="valueExpr">!renderingTable</expression>
</structure>
</list-property>
<cell id="2846">
<property name="colSpan">3</property>
<property name="rowSpan">1</property>
<label id="2862">
<property name="style">ContinueMessage</property>
<text-property name="text" key="ContinuationPreviousPage"></text-property>
</label>
</cell>
</row>
...
...
...
<detail>
<grid id="3721">
<property name="height">0.239in</property>
<property name="width">6.968in</property>
////AT THE BEGINNING OF THE GRID THE VARIABLE IS SET TO TRUE
<method name="onRender"><![CDATA[renderingTable=true;]]></method>
<column id="3722">
<property name="width">1.291in</property>
</column>
...
...
...
<text id="3744">
<property name="style">dataText</property>
<list-property name="visibility">
<structure>
<property name="format">all</property>
<expression name="valueExpr">true</expression>
</structure>
</list-property>
/// AT THE END OF THE FOOTER OF THE TABLE THE VARIABLE IS SET TO FALSE
<method name="onRender"><![CDATA[renderingTable = false;]]></method>
<property name="contentType">plain</property>
<text-property name="content"><![CDATA[ScriptMarker]]></text-property>
</text>
</footer>
...
...
...0 -
If you have something in your masterpage that you want to show on all pages but the first, in your onRender script for the elements in your masterpage, you should put:
if (pageNumber == 1){
this.getStyle().display = "none";
}Warning No formatter is installed for the format ipb0 -
Ok, I was a bit to fast there, as I was so happy to see a nice solution to my problem...
The good news - the onRender method works. The bad news is that the pageNumber is always 1, which in my case always hides the text I want to show on all pages but the first. I tried changing the if-case to pageNumber==2 which had the effect of showing the text on all the pages.
I've found an old question on this forum that seems to have the same problem with pageNumber: http://www.birt-exchange.org/org/forum/index.php/topic/16483-how-do-i-use-variable-pagenumber/).
So... any idea why the pageNumber doesnt follow the page numbering of the pages?0 -
I've found a presentation from eclipsecon where it says that onCreate belongs to the Generation Phase, which is before the Presentation phase. onRender belongs to the Presentation phase. I'm not sure exactly what the different phases means though. Search for "BIRT in depth" to find the presenation and read more.
/aca0 -
/aca,
If you're using the PDF option from the designer, I think it runs the runandrender task, so I don't know if the pageNumber variable gets incremented there. You might try running it in the web viewer and exporting to PDF. This will be more like what you'll see if you run the reports in the deployed viewer with "frameset" and format=pdf in your URL.Warning No formatter is installed for the format ipb0 -
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="76164" data-time="1303400898" data-date="21 April 2011 - 08:48 AM"><p>
/aca,<br />
<br />
If you're using the PDF option from the designer, I think it runs the runandrender task, so I don't know if the pageNumber variable gets incremented there. You might try running it in the web viewer and exporting to PDF. This will be more like what you'll see if you run the reports in the deployed viewer with "frameset" and format=pdf in your URL.<br /></p></blockquote>
<br />
I'm not sure I fully understand your answer so I'll have to get some help from someone who better knows our BIRT settings for before I try anything.0 -
Try going to Run -> View Report -> In Web Viewer. Then from there, go to the toolbar of the viewer and choose the export report option. Select PDF from the drop down and accept. It should work correctly when you do this, I think.Warning No formatter is installed for the format ipb0
-
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="76360" data-time="1303940675" data-date="27 April 2011 - 02:44 PM"><p>
Try going to Run -> View Report -> In Web Viewer. Then from there, go to the toolbar of the viewer and choose the export report option. Select PDF from the drop down and accept. It should work correctly when you do this, I think.<br /></p></blockquote>
<br />
I have the same problem with rendering to word document- I only want to display the footer on page 1.<br />
Prepared a minimal example by having a table wich renders some rows from the sample database- page break interval is set to 0. Setting the page break interval to a different value for my real report is no option! (because in this case it works-> footer is only displayed on first page...).<br />
<br />
I have defined a script in onRender for a text field in footer on the masterpage and the script is only called one time (find out via debugging) for the masterpage. It is not called for all the other pages, so the footer is displayed on each page...<br />
<br />
The script for onRender looks like:<br />
<br />
if(pageNumber>1){<br />
this.getStyle().display="none";<br />
}<br />
<br />
<br />
If I run the example via Birt Designer and show it in the Report Viewer, the footer is displayed only on the first page after clicking on "Render to doc". So it must work somehow!!<br />
But how does this works? What?s the difference to java execution by running the run task at first and afterwards the render task (<a class='bbc_url' href='http://wiki.eclipse.org/Separate_Run_and_Render_(BIRT)_2.1'>http://wiki.eclipse.org/Separate_Run_and_Render_(BIRT)_2.1</a>)? I really need your help with this.<br />
<br />
You can find my example here0 -
When you export to the web viewer, you're using the run task and render task separately. This is why exporting to DOC from the viewer works, but not just choosing DOC in the designer doesn't. So, to get the desired output, you'll just need to run the separate tasks rather than the RunAndRender task. If you're using the viewer and URL's to call the report, using the "run" command uses the runandrender task. Using the "frameset" command uses them separately. Not sure if this answers your question or not. Let me know.Warning No formatter is installed for the format ipb0
-
Thanks for your answer. I understand now, but there must be something other different.
I have used the attached rpt-template in my java code and first execute the run task and afterwards the render task, but it does not work- the footer was displayed on each side (and not only on first side).
So I think that the Report Webviewer adds a hard page break interval when exporting to a word document.
Can you check if the attached example works in your environment when running a separate run and render task in your java code?
My dev env:
Eclipse 3.6.2
Birt 2.6.2
If not, are there any other solutions for me? Thought about using two tables for displaying results. First table is displayed on first page with ca. 20 rows and after rendering a page break will be made (so footer is displayed). The second table displays all rows after row 21. How can I do that with birt scripting?
Thanks,
Jens0 -
Hmmm. I know there was an issue with physical page breaks not calling the end of page events in 2.6.1 and before, but this was fixed in 2.6.2. Maybe it's not quite fully resolved yet. If you run in the web viewer and export to DOC, it does work, but not if you use java to run your report using the run task then the render task. Is this where we're at right now?Warning No formatter is installed for the format ipb0
-
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="77070" data-time="1305566702" data-date="16 May 2011 - 10:25 AM"><p>
Hmmm. I know there was an issue with physical page breaks not calling the end of page events in 2.6.1 and before, but this was fixed in 2.6.2. Maybe it's not quite fully resolved yet. If you run in the web viewer and export to DOC, it does work, but not if you use java to run your report using the run task then the render task. Is this where we're at right now?<br /></p></blockquote>
<br />
Yes, you are completely right! Please try my attached rpt-example from previous post. <br />
I have tried with modified example from <a class='bbc_url' href='http://wiki.eclipse.org/Separate_Run_and_Render_(BIRT)_2.1.'>http://wiki.eclipse.org/Separate_Run_and_Render_(BIRT)_2.1.</a><br />
<br />
The footer is displayed on each page. I have not definied a manual pagebreak. The javascript onRender method on the footer element (a textbox) is only called one time while debugging it with the javascript debugger.<br />
Can you deeper look at it?<br />
<br />
Thanks,<br />
Jens0 -
Sorry for the delay. I have adapted the birt separate run and render example for 2.6.2 and attached the RunTask.java.
Please configure for your environment. The output (PageTest.doc) is attached: footer is on each page.0 -
<blockquote class='ipsBlockquote' data-author="'goldhammer'" data-cid="77361" data-time="1306136716" data-date="23 May 2011 - 12:45 AM"><p>
Sorry for the delay. I have adapted the birt separate run and render example for 2.6.2 and attached the RunTask.java.<br />
Please configure for your environment. The output (PageTest.doc) is attached: footer is on each page.<br /></p></blockquote>
<br />
Any update for this?<br />
<br />
Thanks,<br />
Jens0 -
Try one more thing. If you use a "page variable", you can set its value in the onPageStart method. To show it for the first page, you'd set the value the first time and then the rest of the time set it to "". If you're using a simple text or value, this will work. I don't know if it will work for a very complex header/footer. Use your same java file to run it.Warning No formatter is installed for the format ipb0
-
Hi again!
I had to change 2 things to fix my problem with the pageNumber function.
1. Switch from calling RunAndRenderTask to calling RunTask separately from RenderTask.
The RunTask creates a document that enables page count. The RenderTask creates (in my case) a pdf from the document. The pdf is the end result.
2. Switch the Layout Preference (General property on the report)from Auto Layout to Fixed Layout.
When using auto layout the created document (by RunTask) is one long html document and therefore always equals to 1. Using fixed layout breaks the html document into as many pages as the end result (=pdf) consists of.
I'm not sure this is helpful for your problem, Goldhammer, but thought I should mention it as it is the solution for the original problem :-)
/aca0 -
/aca,
This is the case if only wanting to show it on the first page and not the rest, but it seems to fail otherwise. This is a reported bug in 2.6.2 which I have heard is currently resolved in the next release, 3.7.0, which will be out this summer. (Version number is changing to coincide with the Eclipse version).Warning No formatter is installed for the format ipb0 -
I see. Could this bug be connected to the function for counting total pages of a document? I get a very unreliable total page count on my pdfs - sometimes it is correct and sometimes the total is higher than the actual number of pages. <br />
If so - do u know of any way around it in version 2.6.2? I've looked at 3.7.0 and I dont think we're able to upgrade at the moment.<br />
<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="77926" data-time="1307040909" data-date="02 June 2011 - 11:55 AM"><p>
/aca,<br />
<br />
This is the case if only wanting to show it on the first page and not the rest, but it seems to fail otherwise. This is a reported bug in 2.6.2 which I have heard is currently resolved in the next release, 3.7.0, which will be out this summer. (Version number is changing to coincide with the Eclipse version).<br /></p></blockquote>0 -
The total that you see in the pages is higher than the actual amount of pages in the pdf output? I've never seen this. I've seen it the other way around, but not this way. I have no idea how that would happen. I can explain the other way, but not the way I think you're saying. Am I misunderstanding?Warning No formatter is installed for the format ipb0
-
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="78132" data-time="1307478164" data-date="07 June 2011 - 01:22 PM"><p>
The total that you see in the pages is higher than the actual amount of pages in the pdf output? I've never seen this. I've seen it the other way around, but not this way. I have no idea how that would happen. I can explain the other way, but not the way I think you're saying. Am I misunderstanding?<br /></p></blockquote>
<br />
You have a correct understanding of my problem. An example:<br />
Actual amount of pages: 7<br />
In the header on each page:<br />
1 (9)<br />
2 (9)<br />
... ending with<br />
7 (9)0 -
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="78181" data-time="1307554690" data-date="08 June 2011 - 10:38 AM"><p>
How are you figuring the pages? Are you using the totalPage variable or something else? Can you attach your design?<br /></p></blockquote>
<br />
If I understand your question correct the answer is that I use the RunTask and RenderTask separatly. In earlier BIRT version we used the RunAndRenderTask but that did not enable a page count so I switched. <br />
<br />
In the header where the total page is shown I use both the pagenumber variable and the totalPage variable (that is if by variable you mean Type on the General properties view). The page number is always correct, but the total page is not.<br />
<br />
Unfortunately my report is strongly connected to several java models, but I've reproduced the problem with a report connected to the birt sample db. The problem is however reversed in that report which means it always have a total page of 1. The problem is still that the total page is erroneous so I'll be glad for any tip to what's wrong. I attach the report with the reproduced problem.0 -
The issue in the sample you provided seems to be a bug with BIRT 2.6.2. It is resolved in BIRT 3.7.0. I still don't know how you ended up with a totalPage value larger than the actual pages though. I've not seen that issue ever before. That would be interesting to see. Try downloading 3.7.0RC3 and you'll see that the design attached works as expected. Also try your report on that version to make sure it works as well, since it's a slightly different variation of the same issue.Warning No formatter is installed for the format ipb0
-
The onRender method is a powerful way to improve the performance of your website or application. It can be used to improve the loading time of pages, reduce the number of HTTP requests, and improve the overall user experience. There are several ways to use onRender, and the best way to use it depends on your specific needs. However, a few general tips from https://forgehub.net can help you get the most out of onRender. You can find useful information to help you with your further projects.
-1
Categories
- All Categories
- 123 Developer Announcements
- 54 Articles
- 151 General Questions
- 148 Thrust Services
- 57 OpenText Hackathon
- 37 Developer Tools
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 918 Core Messaging
- 84 Digital Asset Management
- 9.4K Documentum
- 32 eDOCS
- 186 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 8 XM Fax
- Follow Categories