Focal Point
[Case Opened] StyleSheet Link to JavaScript Function With WEBVIEWER ON Breaks.

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

December 20, 2011, 12:20 PM
David Briars
[Case Opened] StyleSheet Link to JavaScript Function With WEBVIEWER ON Breaks.
The following code creates a report and displays it within the browser:
-*
-* Set up environment.
-*
APP PREPENDPATH IBISAMP
-SET &FMT = 'AHTML';
-*-SET &FMT = 'HTML';
-*
-* Create report.  
-*
TABLE FILE GGSALES
 PRINT SEQ_NO
 ON TABLE HOLD FORMAT &FMT
 ON TABLE SET WEBVIEWER ON
 ON TABLE SET WEBVIEWTARG _parent
 ON TABLE SET CACHELINES 200
 ON TABLE SET STYLE *
  TYPE = DATA, COLUMN=SEQ_NO, JAVASCRIPT=dodrilldown(SEQ_NO),
   COLOR=BLUE,
  $
 ENDSTYLE
END
-RUN
-*
-* Display report.  
-*
-HTMLFORM BEGIN
<html>
 <head>
  <title>My Title</title>
  <script language='javascript'>
   function dodrilldown(SEQ_NO) {
    alert('Sequence No =>' + SEQ_NO);
   }
  </script>
 </head>
 <body>
  !IBI.FIL.HOLD;
 </body>
</html>
-HTMLFORM END
-EXIT 

When I run the focexec, -SETting format to 'AHTML', the report renders fine, and the drill down link to the JavaScript function works AOK.

When I run the focexec, -SETting the format to 'HTML', the report renders fine, and the drill down link creates a JavaScript 'Object Expected' error.

When viewing the HTML report, if I click the 'All Pages' button, the drill down works. When I return to the Web Viewer, by clicking the 'back space' button, the links again stop working, yielding the JS 'Object Expected' error.

This message has been edited. Last edited by: David Briars,




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
December 20, 2011, 12:50 PM
Severus.snape
Hi,
Since webviewer divides the HTML into multiple pages each page needs to have the Javascript embedded into it or have a reference to the js file....

here is one way of doing it.

  
APP PREPENDPATH IBISAMP
-*-SET &FMT = 'AHTML';
-SET &FMT = 'HTML';
-*
-* Create report.  
-*

DEFINE FILE GGSALES
JS1/A100 ='<script type="text/javascript" src="http://localhost:8080/approot/baseapp/js1.js"></script>' ;
END

TABLE FILE GGSALES
 PRINT SEQ_NO
HEADING
"<JS1"
 ON TABLE PCHOLD FORMAT &FMT
 ON TABLE SET WEBVIEWER ON
 ON TABLE SET WEBVIEWTARG _parent
 ON TABLE SET CACHELINES 200
 ON TABLE SET STYLE *

  TYPE = DATA, COLUMN=SEQ_NO, JAVASCRIPT=dodrilldown(SEQ_NO),
   COLOR=BLUE,
  $
 ENDSTYLE
END
-RUN
-EXIT




this way each page will have a pointer to the JS file in the baseapp ..

thanks
Sashanka


WF 7.7.03/Windows/HTML,PDF,EXL
POC/local Dev Studio 7.7.03 & 7.6.11
December 20, 2011, 02:09 PM
David Briars
Thank you for the information and technique, Sashanka.

I can see were your technique would be valuable to others in a situation similar to mine.

Unfortunately, in my case, I really do need the -HTMLFORM code that surrounds the report itself.

In my actual case, that the fex in my first entry models, the JavaScript function called submits a Hidden Run Form.

Both the JavaScript function and the hidden run form are stored within the -HTMLFORM code.

This message has been edited. Last edited by: David Briars,
December 20, 2011, 03:15 PM
David Briars
I've performed a 'view source' on the code behind the HTML Format/Webviewer scenario, and do not see any of my HTML and JavaScript code, from within the -HTMLFORM.

It is 'as if' WebFOCUS is doing a 'PCHOLD' instead of a HOLD, under the HTML/Webviewer combination. PCHOLD in the sense that the HOLD file is created, and then it is transferred to the browser.

I want the HOLD file created, without the 'automatic transfer', because I am inserting the report within a -HTMLFORM, via the !IBI.FIL command, in the next step of the fex.

This message has been edited. Last edited by: David Briars,
December 20, 2011, 08:15 PM
njsden
David, perhaps holding the report in either HTMTABLE format for HTML, or AHTMLTAB for AHTML may simplify your including them in the -HTMLFORM section as the resulting HTML will be more "compliant". Otherwise, you will end up with an <HTML> tag inside of another one which is not really a valid document (no matter how forgiving Internet Explorer is) and may make the Javascript functions a bit crazy when parsing the DOM.

-*
-* Set up environment.
-*
APP PREPENDPATH IBISAMP
-SET &FMT = 'AHTML';
-*-SET &FMT = 'HTML';

-SET &HOLDFMT = IF &FMT EQ 'AHTML' THEN 'AHTMLTAB' ELSE 'HTMTABLE';

-*
-* Create report and save resulting HTML table in a HOLD file  
-*
TABLE FILE GGSALES
 PRINT SEQ_NO
 ON TABLE HOLD AS HRESULT FORMAT &HOLDFMT
 ON TABLE SET WEBVIEWER ON
 ON TABLE SET WEBVIEWTARG _parent
 ON TABLE SET CACHELINES 200
 ON TABLE SET STYLE *
  TYPE = DATA, COLUMN=SEQ_NO, JAVASCRIPT=dodrilldown(SEQ_NO),
   COLOR=BLUE,
  $
 ENDSTYLE
END
-RUN
-*
-* Display report.  
-*
-HTMLFORM BEGIN
<html>
 <head>
  <title>My Title</title>
  <script language='javascript'>
   function dodrilldown(SEQ_NO) {
    alert('Sequence No =>' + SEQ_NO);
   }
  </script>
 </head>
 <body>
  !IBI.FIL.RESULT;
 </body>
</html>
-HTMLFORM END
-EXIT 




Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
December 21, 2011, 10:05 AM
David Briars
njsden,

Thank you for your reply.

I had tried HTMTABLE, and received the same JavaScript error. Apologies for not stating that in my original post.

Dave
December 21, 2011, 10:47 AM
njsden
Strange ... upon clicking View Source only <TABLE> ..... </TABLE> are shown, as if the web viewer took controlof the rest of the HTML document ... more playing is needed.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
December 21, 2011, 10:53 AM
njsden
Hmmm, that definitely seems to be the case ... no other content in the HTML document gets rendered as soon as the HOLD file containing the web viewer piece is added.

Though this does not help, at least it explains why your JavaScript is failing ... it just does not seem to be there anymore similar to the rest of the HTML document.

-HTMLFORM BEGIN
<html>
 <head>
  <title>My Title</title>
  <script language='javascript'>
   function dodrilldown(SEQ_NO) {
    alert('Sequence No =>' + SEQ_NO);
   }
  </script>
 </head>
 <body>
  <h1>My heading</h1>
  <br />
  !IBI.FIL.HRESULT;
  <br />
 </body>
</html>
-HTMLFORM END



Taking the WEB VIEWER settings makes the document behave as expected ...



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
December 21, 2011, 11:05 AM
njsden
By analyzing the content of the HTMTABLE file itself, I see this:

 <!--PAGING HTM-->
 <!--VIEWERTARG "_parent"-->
 <!--WEBVIEWHELP "ON"-->
 <!--WEBVIEWALLPG "ON"-->
 <!--VIEWERMULT "OFF"-->
 <!--WEBALLOFF "OFF"-->
 <TABLE BORDER CELLPADDING=1>
 <TR>
 <TD>
 <TABLE CELLPADDING=0 WIDTH="100%"><TR>
 <TD>
 PAGE     1</TD></TR></TABLE></TD>
 </TR>
 <TR>
 <TD ALIGN=RIGHT VALIGN=BOTTOM>
 Sequence#</TD>
 </TR>
 <TR>
 <TD ALIGN=RIGHT>
 <A HREF="javascript:dodrilldown('1');"><FONT COLOR="#0000FF">1</FONT></A>
 </TD>
 </TR>
 <TR>
 <TD ALIGN=RIGHT>
 <A HREF="javascript:dodrilldown('2');"><FONT COLOR="#0000FF">2</FONT></A>
 </TD>
 </TR>
 </TABLE>
 <!--PAGEND-->



However, once added into the -HTMLFORM statement along with the other pieces, Internet Explorer's "View source" only shows this:

<TABLE BORDER CELLPADDING=1>
<TR>
<TD>
<TABLE CELLPADDING=0 WIDTH="100%"><TR>
<TD>
PAGE     1</TD></TR></TABLE></TD>
</TR>
<TR>
<TD ALIGN=RIGHT VALIGN=BOTTOM>
Sequence#</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>
<A HREF="javascript:dodrilldown('1');"><FONT COLOR="#0000FF">1</FONT></A>
</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>
<A HREF="javascript:dodrilldown('2');"><FONT COLOR="#0000FF">2</FONT></A>
</TD>
</TR>
</TABLE>


Plus a set of controls at the bottom of the page.

So, the parsing WebFOCUS must be doing on those "special" lines (<!--PAGING HTM-->,<!--VIEWERTARG "_parent"-->, etc. ) is creating some content in the HTML output that not only adds the "paging controls" at the bottom of the browser but also seems to take precedence or blow completely any other existing content not embedded between <!--PAGING HTM--> and <!--PAGEND-->.

This may be a harder one to hack Frowner



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
December 21, 2011, 11:37 AM
Severus.snape
hi,

WF default WEBVIEWER will send out one HTML page at a time to the browser from the web server....only way to control this is to play around with the system vcpxxx.htm files in WF installation directory or create your own paging feature on the report ...

I am not sure of what your run form requires to accomplish but I tried my hand at coming up with something to start off with...
I know it is a very crude way of doing things.

  

This is the main fex file

-* Set up environment.
-*
APP PREPENDPATH IBISAMP
-*-SET &FMT = 'AHTML';
-SET &FMT = 'HTML';
-*
-* Create report.  
-*

DEFINE FILE GGSALES
JS1/A100 ='<script type="text/javascript" src="http://localhost:8080/approot/baseapp/js1.js"></script>' ;
END

TABLE FILE GGSALES
 PRINT SEQ_NO
HEADING
"<JS1"
 ON TABLE HOLD FORMAT &FMT
 ON TABLE SET WEBVIEWER ON
 ON TABLE SET WEBVIEWTARG _parent
 ON TABLE SET CACHELINES 200
 ON TABLE SET STYLE *

  TYPE = DATA, COLUMN=SEQ_NO, JAVASCRIPT=dodrilldown(SEQ_NO),
   COLOR=BLUE,
  $
 ENDSTYLE
END
-RUN

-*
-* Display report.  
-*
-HTMLFORM BEGIN
<html>
 <head>
  <title>My Title</title>
-*  <script language='javascript'>
-*   function dodrilldown(SEQ_NO) {
-*    alert('Sequence No =>' + SEQ_NO);
-*   }
-*  </script>
 </head>
 <body>

  !IBI.FIL.HOLD;
 </body>

</html>
-HTMLFORM END
-EXIT 

and here is the Javascript file JS1.js

 
   function dodrilldown(SEQ_NO) {
   
    alert('Sequence No => before submitting the form' + SEQ_NO);

   
  
var txtHtml = '<form name=form1 id=form1 method=post target=new  >';
txtHtml = txtHtml + '<type=hidden name=fld1 id=fld1 value="">';
txtHtml = txtHtml + '<type=hidden name=fld2 id=fld2 value="">';
txtHtml= txtHtml + '<type=hidden name="IBIAPP_app" id=IBIAPP_app value="baseapp">';
txtHtml= txtHtml + '<type=hidden name="IBIF_ex" id=IBIF_ex value="google_lat.fex"> </form>';



var prevHtml = document.documentElement.innerHTML;

document.write(txtHtml + prevHtml);


	document.getElementById("fld1").value = SEQ_NO;
	document.getElementById("fld2").value = SEQ_NO * 10;
document.form1.submit();	


}


it submitted the form alright ..


thanks
Sashanka


WF 7.7.03/Windows/HTML,PDF,EXL
POC/local Dev Studio 7.7.03 & 7.6.11
December 21, 2011, 11:43 AM
David Briars
njsden - Thank you for examining this issue. Yes, it is as if my -HTMLFORM html/JavaScript code is removed upon rendering with the viewer, and then 'restored' upon clicking the viewer 'All Pages' icon.

All - I have opened a case with IB on this issue.
December 21, 2011, 11:45 AM
njsden
quote:
This may be a harder one to hack


quote:
... play around with the system vcpxxx.htm files in WF installation directory ...


I guess not for a true hacker Wink

Thanks Sashanka for the example. I'll try to find some time to play with it and see what you propose.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.