Hi! I have to show a traceability report in a more sophisticated presentation format and have choosen the htmlView for this purpose. After generating the HTML and setting the browser to it ( set(browser, html); ) i have to realize that no CSS, Javascript or Backgroundcolor-Attributes were working. Additionally i saw, that the Rightclick->"View Source" has a nearly empty page with "<html></html>" as content, what is not so fine when exporting it into excel. Is there a way ... ... to use CSS within the htmlView ... to use color attributes i.e. <body bgcolor="#ff00ff".... ... to use javascript?
Here is my code:
//
/****************************************************
* Author: Björn Karpenstein
* Stakeholder: n/a
*
* Subversion
* ===================================================
* $Rev:: 49 $: Revision of last commit
* $Author:: karpbjde $: Author of last commit
* $Date:: 2016-03-04 1#$: Date of last commit
*
* Change Control
* ==============
* n/a
*
* Description
* ===========
* This script creates a traceability matrix from a
* RCR as outgoing point
*
* Idea
* ====
* Give the HTML Control a try
* Write with stream to HTML file
* Show progress bar
* Open it with the HTML Control
* Usage of tree table possible
*****************************************************/
// Set script timeout to infinity
pragma runLim, 0;
// Includes
#include "\\\\bbmag2k\\exchange\\doors\\dxl\\lib\\strings.inc";
// Prevent starting from another module than the RCR module
Module m = current;
Object obj = current;
if(name(m) ""!="Configuration Set"&&name(m) ""!="7 Configuration Set")
{
ack "This script should only be opened in the Requirements Change Request module";
halt;
}
string projName = name(current Project);
string changeModuleString="";
string configuresModuleString="";
if(projName=="VarCo")
{
changeModuleString = "/VarCo/20 Sample Project/22 Links/Changes"; // Links zu Change Request
configuresModuleString = "/VarCo/20 Sample Project/22 Links/Configurates"; // Links zu Configurationsmodulen
}
else
{
changeModuleString = "/NDS/90 Administration/Changes"; // Links zu Change Request
configuresModuleString = "/NDS/90 Administration/Configures"; // Links zu Change Request
}
// Global UI Elements
DB mainWindow;
DBE browser;
DBE test;
// Global variables
bool isFirstLoad=true;
void setBrowserHTML(string html){
Buffer b = create;
string s = html;
print s;
b = s;
set(browser, b);
delete b;
}
string myHTML="<!DOCTYPE html>
<html>
<head>
<style>
#trace {
font-family: \"Trebuchet MS\", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#trace td, #trace th {
border: 1px solid #ddd;
text-align: left;
padding: 8px;
}
#trace tr:nth-child(even){background-color: #f2f2f2}
#trace tr:hover {background-color: #ddd;}
#trace th {
padding-top: 12px;
padding-bottom: 12px;
background-color: #4CAF50;
color: white;
}
</style>
<script language=\"javascript\">
alert('Hello!');
</script>
</head>
<body>
<table id=\"trace\">
<tr>
<th>Level 1</th>
<th>Level 2</th>
<th>Level 3</th>
<th>Level 4</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
<td>Alfreds Futterkiste</td>
</tr>
<tr>
<td bcolor=\"#efefef\">Berglunds snabbköp</td>
<td>Christina Berglund</td>
<td>Sweden</td>
<td>Alfreds Futterkiste</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
<td>Alfreds Futterkiste</td>
</tr>
<tr>
<td>Ernst Handel</td>
<td>Roland Mendel</td>
<td>Austria</td>
<td>Alfreds Futterkiste</td>
</tr>
<tr>
<td>Island Trading</td>
<td>Helen Bennett</td>
<td>UK</td>
<td>Alfreds Futterkiste</td>
</tr>
<tr>
<td>Königlich Essen</td>
<td>Philip Cramer</td>
<td>Germany</td>
<td>Alfreds Futterkiste</td>
</tr>
<tr>
<td>Laughing Bacchus Winecellars</td>
<td>Yoshi Tannamuri</td>
<td>Canada</td>
<td>Alfreds Futterkiste</td>
</tr>
<tr>
<td>Magazzini Alimentari Riuniti</td>
<td>Giovanni Rovelli</td>
<td>Italy</td>
<td>Alfreds Futterkiste</td>
</tr>
<tr>
<td>North/South</td>
<td>Simon Crowther</td>
<td>UK</td>
<td>Alfreds Futterkiste</td>
</tr>
<tr>
<td>Paris spécialités</td>
<td>Marie Bertrand</td>
<td>France</td>
<td>Alfreds Futterkiste</td>
</tr>
</table>
</body>
</html>
";
bool onHTMLBeforeNavigate(DBE dbe, string URL, string frame, string body)
{
string buttons[] = {"OK"};
string message = "Before navigate - URL: " URL "\r\nFrame: " frame "\r\nPostData: " body "\r\n";
print message "";
return true;
}
void onHTMLDocComplete(DBE dbe, string URL){
string buttons[] = {"OK"};
string message = "Document complete - URL: " URL "\r\n";
print message "";
string s = get(dbe);
print "url: " s "\r\n";
if(isFirstLoad)
{
setBrowserHTML(myHTML);
isFirstLoad=false;
}
}
bool onHTMLError(DBE dbe, string URL, string frame, int error){
string buttons[] = {"OK"};
string message = "Navigate error - URL: " URL "; Frame: " frame "; Error: " error "\r\n";
print message "" ;
return true;
}
void onHTMLProgress(DBE dbe, int percentage){
string buttons[] = {"OK"};
string message = "Percentage complete: " percentage "%\r\n";
print message;
return true;
}
void showHTMLCallBack(DB x)
{
string newHTML="<html><head><title>test</title></head><body bgcolor=\"#ff00ff\"></body></html>";
setBrowserHTML(myHTML);
}
void main(void)
{
mainWindow=create("Traceability Master Professional");
browser = htmlView(mainWindow, 1024, 768, "", onHTMLBeforeNavigate, onHTMLDocComplete, onHTMLError, onHTMLProgress);
test=apply(mainWindow, "Show HTML", showHTMLCallBack);
realize mainWindow;
show mainWindow;
}
main();
Bjoern_Karpenstein - Wed Mar 09 05:18:15 EST 2016 |
Re: Why DBE htmlView is not showing CSS and BGCOLORs? Perhaps you have a logical reason for posting on this forum -- perhaps you can explain.
Note: This forum is about dxl not about html. |
Re: Why DBE htmlView is not showing CSS and BGCOLORs? I also tried the htmlview at some time with no success. It seems they disabled javascript out of security reasons. The problem with the CSS I experienced too - it seems they ignore the "head" content. Suggestion: Write to an HTML File and open execute the HTML file (which should open it up with the default browser). Regards, Mathias |
Re: Why DBE htmlView is not showing CSS and BGCOLORs? Mathias Mamsch - Mon Mar 14 03:38:33 EDT 2016 I also tried the htmlview at some time with no success. It seems they disabled javascript out of security reasons. The problem with the CSS I experienced too - it seems they ignore the "head" content. Suggestion: Write to an HTML File and open execute the HTML file (which should open it up with the default browser). Regards, Mathias Hi Mathias!
using htmlView promised to be able to make some fancy user interfaces, but i guess your proposal to open the default browser (i.e. with system iexplore.exe <sitename>) would be the best approach to use the ability of HTML within DXL-Generation.
Thank you very much for understanding me :)
With best regards, |
Re: Why DBE htmlView is not showing CSS and BGCOLORs? There is an example script in DXL ref about htmlView, it displays the BBC web site in quite readable fashion - I would presume that BBC uses at least CSS in their formatting. I think that the htmlView DBE is just an IE canvas, so it should run evertyhing which IE does. Note that htmlView and Björn's example HTML works at least with inline CSS formatting, e.g. <th style="border: 1px solid #ddd; text-align: left; padding: 8px;">Level 1</th>
... it is of course little bit silly to modify each element like that, but if it works, then maybe. |
Re: Why DBE htmlView is not showing CSS and BGCOLORs? PekkaMakinen - Mon Mar 14 04:24:11 EDT 2016 There is an example script in DXL ref about htmlView, it displays the BBC web site in quite readable fashion - I would presume that BBC uses at least CSS in their formatting. I think that the htmlView DBE is just an IE canvas, so it should run evertyhing which IE does. Note that htmlView and Björn's example HTML works at least with inline CSS formatting, e.g. <th style="border: 1px solid #ddd; text-align: left; padding: 8px;">Level 1</th>
... it is of course little bit silly to modify each element like that, but if it works, then maybe. Hi PekkaMakinen,
The funny thing is, when you go to an URL of a real webserver, the CSS and Javascript is working.
But when you use the
set(htmlView, htmlBuffer)
Command to set a generated HTML-String to the browser, the Browser is not considering <head>-CSS or <body>-CSS or <script>-Tags.
Maybe they changed the security for local intranet websites in the htmlView-DXL-Component.
With best regards, |
Re: Why DBE htmlView is not showing CSS and BGCOLORs? Bjoern_Karpenstein - Mon Mar 14 04:28:26 EDT 2016 Hi PekkaMakinen,
The funny thing is, when you go to an URL of a real webserver, the CSS and Javascript is working.
But when you use the
set(htmlView, htmlBuffer)
Command to set a generated HTML-String to the browser, the Browser is not considering <head>-CSS or <body>-CSS or <script>-Tags.
Maybe they changed the security for local intranet websites in the htmlView-DXL-Component.
With best regards, The style definitions work if you move them from <head> to be inside of <body>. That is not valid HTML, but browsers seem not to care about validity. Javascript does not work this way. |