Focal Point
[WORK-AROUND] Drilldown to Javascript - HTML vs. AHTML

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/8377091076

April 16, 2014, 04:33 PM
stur0063
[WORK-AROUND] Drilldown to Javascript - HTML vs. AHTML
I have a *.fex in a frame on an HTML page.

In the *.fex, I can add a drill down to a JavaScript funciton located on the page with the following:

TYPE=DATA,
COLUMN=N3,
DRILLMENUITEM='Search on Consolidated',
JAVASCRIPT=window.parent.setCustSearch( \
N2 \
),

This works great when the output is HTML.

However, when I swith my report to:

ON TABLE PCHOLD FORMAT AHTML

This no longer works - and I'm not sure what's going on.

Anyone have a working example of a JavaScript Drilldown in a AHTML report? I'm just trying to bust out of the iFrame the report is in - pass 1 column of data from the *.fex to the javascript function in the HTML page.

This message has been edited. Last edited by: stur0063,


webFOCUS 8207.15
WindowsServer 2019
April 17, 2014, 08:12 AM
stur0063
Here's a *.fex and *.html example using Car.

carJunk.fex
TABLE FILE CAR
PRINT 
     CAR.ORIGIN.COUNTRY
     CAR.COMP.CAR
     CAR.CARREC.MODEL
ON TABLE SET PAGE-NUM NOLEAD 
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
     INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,
$
TYPE=DATA,
     COLUMN=N1,
     DRILLMENUITEM='Regurgitate Country',
          JAVASCRIPT=window.parent.alertCountry( \
     N1 \
     ),
$
ENDSTYLE
END


Here's the html page - with the javascript function I'd like to get working. Does work if
ON TABLE PCHOLD FORMAT HTML. Does not work if ON TABLE PCHOLD FORMAT AHTML

htmlJavascript.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD>
<META id=RLT_STANDARDS_MODE_META content=IE=9 http-equiv=X-UA-Compatible>
<META name=mycharsetmeta content="text/html; charset=ISO-8859-1" http-equiv=Content-Type>
<META name=Generation content="Created in release 8005, Generation 3">
<SCRIPT type=text/javascript>//confidential_id=IBI_OptionsScript
var szHtmlAlias="/ibi_apps/ibi_html";var szRunTimeHtmlAlias="runTimeHtmlAlias";var cgipath="cgipath";var ibirls="ibirls3";var rltdyncalendar="rltdyncalendar";var map="ibimap";var olap="olap";var olappanebase="olappanebase";var olapdrill="olapdrill";var ibiOptions = new Array(cgipath,ibirls);var nlsScript="/javaassist/nls.js";var nlsVarsScript="/javaassist/nlsvars.js";var glbScript="/javaassist/ibi/html/js/ibigbl.js";var replacePart="<replace>";
var scriptTemplate='<SCRIPT src="'+replacePart+'" type="text/javascript"><\/SCRIPT>';if(typeof(szRunTimeHtmlAlias) === 'string' && szRunTimeHtmlAlias.indexOf('/') == 0)szHtmlAlias=szRunTimeHtmlAlias;document.write(scriptTemplate.replace(replacePart, szHtmlAlias + nlsScript));document.write(scriptTemplate.replace(replacePart, szHtmlAlias + nlsVarsScript));document.write(scriptTemplate.replace(replacePart, szHtmlAlias + glbScript));</SCRIPT>

<SCRIPT type=text/javascript>//confidential_id=IBI_ibigblloadCss
if(typeof ibigblloadCss === 'function'){ibigblloadCss(null);addIntlTranslatedJS("composertrans.js");}else {alert("JavaScript alias '/ibi_apps/ibi_html'  is not valid");window.location("about:blank");}</SCRIPT>
<TITLE>HtmlPage</TITLE><LINK id=ITEM2 rel=stylesheet type=text/css rtFileName="cgipathsub/ibi_html/javaassist/ibi/html/composer/themes/nonBindows/IBI-Themes/default_theme.css"><LINK id=IBI_THEME_CSS rel=stylesheet type=text/css desc="Information Builders" rtFileName="cgipathsub/ibi_html/javaassist/ibi/html/composer/themes/nonBindows/IBI-Themes/ibi.css">
<SCRIPT for=window type=text/javascript eventname="onload">window.onload = function() { window_onload(); }</SCRIPT>

<SCRIPT>//confidential_id=clientEventHandlersJS

//Begin function window_onload
function window_onload() {
 
UpdateData();
 
// TODO: Add your event handler code here
//add onInitialUpdate() function to make changes before initial run of the reports
}
//End function window_onload

//Begin function button1_onclick
function button1_onclick(ctrl) {
// TODO: Add your event handler code here
OnExecute(ctrl)
}
//End function button1_onclick


function alertCountry(daText)
{
	alert('in alertCountry - which is on the *.html page');
	alert(daText);
}</SCRIPT>
</HEAD>
<BODY style="OVERFLOW: auto" class=IBI_PageBg maptype="0" thumbnailscale="4" elementtype="21" edaconnectionrequired="true"><IFRAME style="Z-INDEX: 1; POSITION: absolute; WIDTH: 910px; HEIGHT: 470px; TOP: 150px; LEFT: 90px" id=iframe1 class="IBIfield IBI_Frame IBI_rounded_m" tabIndex=1 name="iframe1"></IFRAME><INPUT style="Z-INDEX: 2; POSITION: absolute; WIDTH: 120px; HEIGHT: 20px; TOP: 60px; LEFT: 180px" id=button1 language=javascript class="IBIfield IBI_button" tabIndex=2 onclick=button1_onclick(this) value=Button type=button autoExecute="true" requests_list="0" name="button1"><INPUT style="POSITION: absolute; TOP: -100px; LEFT: -100px" id=layoutinfo type=hidden resourcectrlids="ITEM2;IBI_THEME_CSS" name="inputhidden1"><INPUT style="POSITION: absolute; TOP: -100px; LEFT: -100px" id=ibiapp_app value=~jeremysturgill type=hidden ismre="1" name="ibiapp_app"><INPUT style="POSITION: absolute; TOP: -100px; LEFT: -100px" id=ibif_ex value=/WFC/Repository/H2OSales/~jeremysturgill/ahtmlDrilldown/htmlJavascript.htm type=hidden name="ibif_ex"><xml id=focus_xmlelement><script type="text/xml"><rootxmlnode focoption="_FOC_NULL"><variables></variables><input_controls></input_controls><requests nextrequestsid="0"><request requestid="0" sourcetype="typeFex" targettype="iframe" targetname="iframe1" ibif_ex="/WFC/Repository/H2OSales/~jeremysturgill/ahtmlDrilldown/carJunk.fex" activereport="0" reportcolumns="" reportrealcolumns="" ibiapp_app="~jeremysturgill"></request></requests><other_bound_objects></other_bound_objects></rootxmlnode></script>
</xml></BODY>
<SCRIPT type=text/javascript>//confidential_id=IBI_loader
if(typeof doBeforeLoad === 'function'){doBeforeLoad();}function AdjustChildrenPosition(){
}
</SCRIPT>
</HTML>
<!-- cc ksnl -->



I'd appreciate it if someone could point me in the right direction. Why does it work with HTML - but not AHTML? Something different with the DOM in an AHTML?


webFOCUS 8207.15
WindowsServer 2019
April 17, 2014, 11:44 AM
stur0063
I'm seeing this error, in Chrome, when set to AHTML. (No errors when HTML)

Uncaught ReferenceError: ITALY is not defined

Clicking Source tab in Chrome developer tool:

window.parent.alertCountry=ITALY


webFOCUS 8207.15
WindowsServer 2019
April 23, 2014, 09:04 AM
stur0063
Response from IBI (in case someone elese wants to do something similar)

Custom JavaScript cannot be placed in an AHTML file. There is an optional
product, the Active Technologies API which is used for embedding Active Reports
inside web pages and does not have the restriction you have found. But, the
API is overkill for your application.

I can test a workaround with drilling to a fex which contains HTML and
JavaScript between the -HTMLFORM BEGIN and -HTMLFORM END statements. This will
allow parameters to be passed.

* Are you interested in this approach? If yes, I'll make a prototype and
then review it with you.


webFOCUS 8207.15
WindowsServer 2019
May 21, 2014, 04:17 PM
Francis Mariani
stur0063,

Thanks for investigating this for us. I have the same situation - I would like to call a JavaScript function instead of a Focexec in a drilldown of an AHTML report - I'd like to open the new window without some of the browser window components, address bar, et al. I wish this post wasn't labelled "SOLVED".


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
May 21, 2014, 04:26 PM
stur0063
Francis,

I worked with Barry and we discovered the following:

If it's a MultiDrill - it does not work. (Assumption is the AHTML javascript stomps all over my little javascript call)

If make it a single drill – by removing
DRILLMENUITEM='Search on Customer Number',

it will work...HOWEVER - you lose the other nifty stuff that comes along for the ride in the AHTML. So – it can work – but it’s not as elegant as I’d like.

There's a NFR for this to work with MULTI-DRILL

If you suggest a new label for this post - I'll be happy to change it form SOLVED to X.


webFOCUS 8207.15
WindowsServer 2019
May 21, 2014, 04:34 PM
Francis Mariani
"WORK-AROUND" ?

Thanks for the update to this.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
May 27, 2014, 06:12 PM
Francis Mariani
Here's something:

TABLE FILE CAR
PRINT 
     CAR.ORIGIN.COUNTRY
     CAR.COMP.CAR
     CAR.CARREC.MODEL
ON TABLE SET PAGE-NUM NOLEAD 
ON TABLE NOTOTAL
ON TABLE HOLD AS HREPORT1 FORMAT AHTMLTAB
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *

TYPE=DATA,
     COLUMN=N1,          JAVASCRIPT=alertCountry( \
     N1 \
     ),
$
ENDSTYLE
END
-RUN

-HTMLFORM BEGIN
<HTML>
<HEAD>
<SCRIPT>
function alertCountry(Col1)
{
alert(Col1);
}
</SCRIPT>
</HEAD>
<BODY>
!IBI.OBJ.ACTIVEREPORTJS;
!IBI.FIL.HREPORT1;
</BODY>
-HTMLFORM END


I found !IBI.OBJ.ACTIVEREPORTJS; in the Dev Studio documentation - not much there though.

Creating Reports With WebFOCUS Language > Saving and Reusing Your Report Output > Choosing Output File Formats > FORMAT AHTMLTAB

I've never used AHTMLTAB format nor ACTIVEREPORTJS but this stuff worked for me! In a drilldown, I can now call a JavaScript function that opens a new window without toolbars and then runs a report with this window. Wunderbar.

(2014/05/28 - corrected my sample code to use AHTMLTAB)

This message has been edited. Last edited by: Francis Mariani,


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
May 28, 2014, 08:40 AM
Ram Prasad E
Francis,

Thanks for sharing this. I have similar requirement where I need to call JS function as a drill down from HTML page with On-demand pagination. I will try out with your code.

Thanks,
Ram


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
May 28, 2014, 06:01 PM
David Briars
quote:
...In a drilldown, I can now call a JavaScript function that opens a new window without toolbars and then runs a report with this window...

Thanks for your post Francis!

Drilling down from Active Reports is a key component of our system. We use the same template/model you have provided here. (My only suggestion would be to consider changing the format AHTML to AHTMLTAB.)

With this technique, the power/flexibility you have in the JavaScript, to then setup the next open window and report call is very great.

Thanks again.




Pilot: WebFOCUS 8.2.06 Test: WebFOCUS 8.1.05M Prod: WebFOCUS 8.1.05M Server: Windows Server 2016/Tomcat Standalone Workstation: Windows 10/IE11+Edge Database: Oracle 12c, Netezza, & MS SQL Server 2019 Output: AHTML/XLSX/HTML/PDF/JSCHART Tools: WFDS, Repository Content, BI Portal Designer & ReportCaster
July 21, 2014, 11:53 AM
Francis Mariani
Unfortunately, as previously pointed out, my suggestion does not work with multi-drilldown (DRILLMENUITEM).


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
July 22, 2014, 11:53 AM
BarryS
Hi

You may want to put the AHTML in an HTML file and drill down to javascript. From the JavaScript function you can have control over what is being called. I am in App Studio training til Wednesday and will be in the office on Thursday if you want to open a case for this.

Thanks Barry Solomon


WebFOCUS 8103, Windows, App Studio
July 30, 2014, 08:55 AM
J
This is a great workaround, but wouldn't it be easier to just have the active report javascript files already included in the html page by default? Can you point us out to where those javascript files are if that isn't possible?


WebFOCUS 7.7.03/8.0.08
Dev Studio 7.7.03/8.0.08
App Studio 8.0.08
Windows 7
ALL Outputs
July 30, 2014, 09:18 AM
J
nvm... I found the files in srv80\home\etc. Francis you may be able to include the multidrill js file located in this directory or whatever else you need to get your report working. You may want to contact IBI about the best way to go about this.


WebFOCUS 7.7.03/8.0.08
Dev Studio 7.7.03/8.0.08
App Studio 8.0.08
Windows 7
ALL Outputs
July 30, 2014, 11:52 AM
J
If you intend to use the workaround Francis mentioned the documentation says to use:
 SET AROUTPUT = DATALOOK
Creating an Active Technologies Report >> How to Control the Generation of the Active Technologies for HTML Output File


WebFOCUS 7.7.03/8.0.08
Dev Studio 7.7.03/8.0.08
App Studio 8.0.08
Windows 7
ALL Outputs
July 30, 2014, 12:12 PM
Francis Mariani
quote:
SET AROUTPUT = DATALOOK

looks interesting, but is for v8 and above. I'll see if I can sneak it into a v7.7.05 report I'm having trouble with.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
July 30, 2014, 01:17 PM
J
quote:
SET AROUTPUT = DATALOOK

NVM I just tried that and it caused your technique to fail (at least in APP STUDIO).


WebFOCUS 7.7.03/8.0.08
Dev Studio 7.7.03/8.0.08
App Studio 8.0.08
Windows 7
ALL Outputs