Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » JavaScript resource files(External js functions not called from text element)
JavaScript resource files [message #938529] Tue, 09 October 2012 20:16 Go to next message
David Good is currently offline David Good
Messages: 34
Registered: September 2012
Member
Hi,

Whenever possible I create my JavaScript functions used by reports in external files and add them to the report via the resources ui.

I have just completed a report where I added row hover highlights, using the following functions in a text/html element placed on the report, above the first table:

<script>

// add highlighted background on hover
function hoverShadeOn(bmark, rgb) {
var currElement;
currElement = document.getElementById(bmark);
currElement.style.backgroundColor = "RGB(" + rgb + ")";
}

// remove highlighted background on hover
function hoverShadeOff(bmark){
var currElement;
currElement = document.getElementById(bmark);
currElement.style.backgroundColor = "transparent";
}

</script>



I set the first element of each row to highlight the rest of the row when hovered, using a text/html element as follows:

<a href = ""
onmouseover="hoverShadeOn('ProductLine_<VALUE-OF>row["productCode"]</VALUE-OF>','221,221,221');"
onmouseout="hoverShadeOff('ProductLine_<VALUE-OF>row["productCode"]</VALUE-OF>');"
>
<VALUE-OF>row["productLine"]</VALUE-OF>
</a>

I set it's bookmarks appropriately and it works as expected.


I decided to externalize the hoverShadeOn and hoverShadeOff functions as I will use them in other reports. I copied everything except the script tags and comments to a .js file (hoverShading.js) as follows:

function hoverShadeOn(bmark, rgb) {
var currElement;
currElement = document.getElementById(bmark);
currElement.style.backgroundColor = "RGB(" + rgb + ")";
}

function hoverShadeOff(bmark){
var currElement;
currElement = document.getElementById(bmark);
currElement.style.backgroundColor = "transparent";
}

I then removed the text/html element at the top of my report which held the functions. My hover action stops working.

As I have stated, I use external js functions often but in BIRT functions such as initialize or dataset beforeOpen.

Text elements must work differently? I considered needing to add the script tag to my function call as follows but it does not work.

onmouseover="<script>hoverShadeOn('ProductLine_<VALUE-OF>row["productCode"]</VALUE-OF>','221,221,221');</script>"

What am I missing here?

Thanks,
Dave
Re: JavaScript resource files [message #939834 is a reply to message #938529] Thu, 11 October 2012 00:44 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Dave

The js files in the resource folder are for server side global js files, not client side. Why not just add a text element to the top of the report that includes your js files.

<script type="text/javascript" src="http://localhost:8080/2.5.2/externalmyjsfile.js"></script>
<script type="text/javascript">
alert(getMyValue());
</script>


Jason


Jason Weathersby

BIRT Exchange
Re: JavaScript resource files [message #968059 is a reply to message #939834] Fri, 02 November 2012 03:04 Go to previous messageGo to next message
David Good is currently offline David Good
Messages: 34
Registered: September 2012
Member
HI Jason,

Yes that makes sense. I had thought the js (resource) and css (styles->'Use CSS file') are linked for use by the client, but I guess when we 'Use CSS file' the css is embedded while the javascript must be linked as you have stated? Thanks for clearing that up

Sorry for the late replay, your answer is much appreciated.

Thanks,
David
Re: JavaScript resource files [message #968106 is a reply to message #968059] Fri, 02 November 2012 03:44 Go to previous message
David Good is currently offline David Good
Messages: 34
Registered: September 2012
Member
On a slightly different note - Do you know where I can subscribe to get (or at least manually download) a set of release notes, each time a new version of BIRT designer or viewer is released? I can find the general 'New and Notable Features within BIRT X.X' version notes but I am after more granular build notes.

The reason I ask is that Tomcat 7.0.32 is causing the (v 4.0.2) viewer's jsp comments to error (see http://mail-archives.apache.org/mod_mbox/tomcat-dev/201210.mbox/%3Cbug-53986-78@https.issues.apache.org/bugzilla/%3E).

I wanted to see if the latest viewer version has fixed this but could not find the build release notes on eclipse website and have had to download the new viewer and check files to see that comment tags have not been changed. This may be a bug with Tomcat which they will fix but some individual build release notes would be handy.

Thanks again for your assistance.
David
Previous Topic:ODBC JDBC BIRT
Next Topic:Aggregation to find a "-1" in an array
Goto Forum:
  


Current Time: Thu Apr 24 01:56:24 EDT 2014

Powered by FUDForum. Page generated in 0.02561 seconds