|
Re: Custom server side javascript issue in Birt web viewer [message #906126 is a reply to message #906082] |
Fri, 31 August 2012 16:57 |
|
Take a look at this post:
http://birtworld.blogspot.com/2012/07/using-global-js-function-across-birt.html
Add the js file to the report and put the js file in the resource folder.
Jason
On 8/31/2012 11:21 AM, birt user wrote:
> I have created a javascript for logging. The name of the file is
> logging.js. Here is the code
> ========================================
> var logFile="F:/logFile.txt";
> var loggingEnabled=true;
> var printWriter;
> function createLogger(method,message)
> {
> if (loggingEnabled && printWriter == null)
> {
> importPackage( Packages.java.io );
> fos = new java.io.FileOutputStream( logFile, true );
> printWriter = new java.io.PrintWriter( fos );
> }
> if(loggingEnabled && printWriter != null)
> {
> logMessage(method,message);
> }
> }
> function logMessage(method,message)
> {
>
> if (loggingEnabled && printWriter != null)
> {
> printWriter.println(method + ":" + message);
> }
> }
> function closeLogger(method,message)
> {
> if (loggingEnabled && printWriter != null)
> {
> logMessage(method,message);
> printWriter.close();
> }
> }
> ===================================================
> I have added this script under Resources (javascript files) section of
> the report. When i use these js functions in my report and run it under
> eclipse or report designer, no problems
>
> But when I copy the script and the report to birt viewer, it gives me error
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Wrapped org.eclipse.birt.core.exception.CoreException: There are errors
> evaluating script "createLogger":
> ReferenceError: "createLogger" is not defined. (<inline>#1)
> (/report/method[@name="initialize"]#2) (Element ID:1)
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> I copied the script under tomcat birt folder and also copied it under
> webcontent folder. Not sure why it does not work under viewer. Any help
> would be appreciated
>
> thanks
>
> birt user
|
|
|
|
Re: Custom server side javascript issue in Birt web viewer [message #911403 is a reply to message #911010] |
Tue, 11 September 2012 14:29 |
|
Can you post the report? Did you set a resource folder in your designer. I am wondering if the full path to the js file is in the report. It should not be. Try creating a resource folder in your project, something like resources and set this as the resource folder in your designer preferences. See the blog reference I posted earlier to see how to do this. Put the js file in the resource folder and add it to the report. Next create a folder in the webviewer named something like resources, and put the js file in this folder. Set the BIRT_RESOURCE_PATH to the value resources and try the deployed report.
Jason
|
|
|
Powered by
FUDForum. Page generated in 0.23134 seconds