Template Definition

Modify the template provided with Genero Desktop Client ActiveX to customize behavior when it's started and stopped.

When you install GDC/AX, a basic template is installed. This template can be modified to fit your needs. The default template consists of two files:

Microsoft has released an update for Internet Explorer that modifies the way ActiveX is handled. (Very) old templates must be changed accordingly. See IE ActiveX update (KB9 12945), Ms Technet about KB 912945, and MSDN about ActiveX activation

The template is composed of several JavaScript functions:

function startIt() {
// first activate ActiveX.
gdc = loadGDC("divgdc", "GeneroDesktopClient", "2,40,6,0", "$(connector.uri)");
checkGDC();
}

This function is called when the HTML body is loaded. This will starts the GDC main object. The version given in a parameter is the minimum version required. If the version is too old, ActiveX will update itself automatically.

// this function checks if GDC object is ready. If not, wait 1 second and retry.
function checkGDC(){
if(timerID) {
clearTimeout(timerID);
timerID = 0;
}

// gdc is not ready, wait a few seconds...
if (!gdc || !gdc.enabled) {
retryCount++;
if (retryCount <= maxRetry) {
timerID = setTimeout("checkGDC()", 1000);
} else {
if (confirm("Genero Desktop Client could not be started within the
 correct time.\nKeep waiting ?")){ 
retryCount = 0; 
timerID = setTimeout("checkGDC()", 1000); 
return; 
} 
document.getElementById("divwait").style.display = 'none'; 
document.getElementById("divgdc").style.display = 'block'; 
alert("Genero Desktop Client can't be started, please contact your
 system admin");
}
}
else {
//gdc is loaded, hide the loading panel and show gdc panel 
document.getElementById("divwait").style.display = 'none'; 
document.getElementById("divgdc").style.display = 'block'; 
configureGDC(); 
return startApplication("$(application.id)", "$(application.querystring)"); }
}

Basically, the GDC object will be ready when the function gdc.enabled exists. So the checkGDC function checks if gdc.enabled exists; if not it waits 1 second and retries. After 30 retries, we give up, something must be wrong.

You can configure the number of retries with var maxRetry = 30. Once GDC is ready, we can configure it and start an application:
function configureGDC() {

//uncomment following line to enable Admin Mode
//gdc.setAdmin(true);

//uncomment following line to enable Debug Mode
//gdc.setDebug(true);

//uncomment and modify the following line if you want to change the
 ping timeout (300 s by default)
//gdc.setPingTimeOut(120);

//uncomment and modify the following line if you want to change the
 proxy (using system settings by default)
//gdc.setProxy("myproxy")

// this is to ensure that any popup window will appear in front of the browser
gdc.setFocus();
}

You can configure some options which are usually available using the command line, like admin or debug mode. Refer to Genero Desktop Client ActiveX APIfor details on all available options.

The next step is to start the application.

function startApplication(appName, appQueryString) {
// the serverUrl must be set BEFORE starting the application
if ("$(connector.uri)" != ""){
gdc.setSrvUrl(location.protocol + "//" + location.host + "$(connector.uri)" +
 "/wa/r/" + appName + "?" + appQueryString);
} else {
gdc.setSrvUrl(location.href);
}
gdc.setPictureUrl("$(pictures.uri)");
gdc.setAppName(appName);

return false;
}

The two main functions are setSrvUrl and setAppName. Their names are slightly inappropriate today, but they are kept for compatibility reasons.

function preventClose() {
if ( !gdc ) {
return;
}

// if there still an application running, display a message on close browser.
if (gdc.applicationCount > 0){
event.returnValue = "Genero Desktop Client";
}
}

This last function is called by Internet Explorer when the page is closed; a message box indicates that event.returnValue (here "Genero Desktop Client") will be stopped if the page is closed, and asks the user to confirm the close. We check that there are applications running before displaying this message - otherwise Internet Explorer can do its job safely.

var timerID = 0;
var gdc = 0;
var retryCount = 0;
var maxRetry = 240; //the script will test if GDC is loaded for 240 seconds

These few "global" variables are used to test if GDC is ready for 30 seconds. Here you can change maxRetry if you want the page to wait more or less time.