IBM Doors DXL: A DXL generated HTML string shall be shown in a browser

Problem

A DXL generated HTML string should be shown in a browser

Approach

Using the DBE Element htmlView it is possible to use an instance from the installation of the Clients Internet Explorer and show generated HTML Files.

Solution

// 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="Add your html code here";

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)
{
  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();

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.