Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » How to modify Data Element hyperlink via script?(What is proper use of getAction() in onPrepare script?)
icon8.gif  How to modify Data Element hyperlink via script? [message #699203] Thu, 21 July 2011 00:56 Go to next message
Lawrence Gaalswyk is currently offline Lawrence Gaalswyk
Messages: 2
Registered: July 2011
Junior Member
This should be simple, but I cannot find the answer...

I have a data element in a report which I want to be a URL hyperlink only if the data starts with the text "AB". As a first step, I need help with setting the hyperlink to a URL via script -- then I can set it to "none" or to a specific URL with an if/else, based on the data element's value.

I have read Jason W's article here:
eclipse.org/birt/phoenix/deploy/reportScripting.php

... specifically, the following text seems to be exactly what I need:
Modifying Hyperlinks
The hyperlink for a data element can be modified in the onPrepare by using code similar to:
this.getAction().URI = "'http(COLON-SLASH-SLASH)www.google.com'";
Notice the single quotes within the double quotes.

However, I have the following in the onPrepare script of my report's data element, and it does not work:
this.helpText = "Click here for Google";
this.getAction().URI = "'http(COLON-SLASH-SLASH)www.google.com'";

The helpText works (it pops up when I hover over the element), but the data item is not a clickable URL when I "view report as HTML" in BIRT Designer.

I am using BIRT Report Designer 2.2.1.

Any help / suggestions will be much appreciated.

Note the (COLON-SLASH-SLASH) in above links should be replaced with :// -- I had to do this because this forum says "You cannot use links until you have posted more than 5 messages".

Thank you,
Lawrence
(no subject) [message #699433 is a reply to message #699203] Thu, 21 July 2011 10:31 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

If you want the hyperlink to be dynamic, meaning it changes for every
instance of the data item, you need to use an onCreate event. For example:

if( this.getValue() > 40 ){
var myaction =this.createAction();
myaction.setHyperlink("http://www.google.com", "_blank");
this.action = myaction;
}

I am attaching a 2.2.1 example.

Jason

On 7/21/2011 12:56 AM, Lawrence Gaalswyk wrote:
> this.helpText = "Click here for Google";
> this.getAction().URI = "'http(COLON-SLASH-SLASH)www.google.com'";
Re: (no subject) [message #699545 is a reply to message #699433] Thu, 21 July 2011 14:18 Go to previous message
Lawrence Gaalswyk is currently offline Lawrence Gaalswyk
Messages: 2
Registered: July 2011
Junior Member
My problem is solved using your example. THANK YOU, Jason, once again!
Previous Topic:Web Service Data Sources
Next Topic:Auto Drill-Through
Goto Forum:
  


Current Time: Thu Aug 28 23:39:47 EDT 2014

Powered by FUDForum. Page generated in 0.01885 seconds