Archive

Posts Tagged ‘Dialoge’

XPages: Dojo dialogues

22/09/2011 2 comments

Again, XPages were cracking my head, this time with dialogues.

What was the scenario?

Some function in one of my application should be packed into dialogues. For instance one agent, which offers an excel-file for download which needs two different buttons to pass on some parameters to the agent. Therefore I had to call the URL of the agent, directly. Useally a simple task.
In rationally working browsers all works fine, until some genius thought it would be quite intelligent two try to click one button shortly after the other one. First button was working fine, but the second one wasn’t reacting. I fact, after that, nothing was working after that. When I reloaded the page, everything was working fine again, until someone was trying to click both buttons again.
The reason for this behavior was Dojo. One clever developer thought, to reduce the server load, he could implement a timeout for special situations. This function is hidden in the depths of theDojo source files. Who wants to check that, look here:

~NotesDatadominojsdojo-1.4.3ibmxspwidgetlayout

There are the source files of Dojo, quite useful if you want to debug your program effectively and never want stuck in some error messages like “Error in line 16, charackter 18564” again, because there are also the uncompressed sources.

There is one tiny file, called xspClientDojo.js with a tiny, nasty function:

/**
* The number of milliseconds allowed between page submissions,
* see XSP.canSubmit().
*/
// 20 sec if the latency after to re-enable the submission
// - asked by customers
this.submitLatency = 20*1000;

this._allowDirtySubmit = true;
this._dirty = false;
this._dirtyFormId = null;

this.djRequire = function x_djreq(name) {
   return dojo["require"](name);
}

“Asked by customers”, it’s sad that developers have to excuse themself for the wishes of some customers.
The bottom-line is that 20 seconds has to pass by between two submissions. Actually, that works! if you let pass 20 seconds after the first submissions, everything works fine again, even in my application.

Of course it is a little bit nasty to let customers wait 20 seconds between all submissions, tempting, but not acceptable. But Dojo has some workaround for that:

/**
* If the page is not submitted after a call to canSubmit(),
* this should be invoked to re-enable page submission.
* @return void
*/
this.allowSubmit = function x_as() {
   this.lastSubmit = 0;
}

This function resets the timestamp of the last submissions and allows some new submissions.

If we add this line of code to our program, we can avoid this problem.

XSP.allowSubmit();

You can imagine this wasn’t the end of the story. I mentioned rationally working browsers, in other browsers (Internet Explorer) it wasn’t possible to get the dialogues running.
Useally, the following meta header solves this problem:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

Unfortunately, most physical laws of the web are rather optional guidelines in XPages.

Dojo knows this problem, there is a fix for that, you can find it here: Bugs.dojotoolkit.org

Due to some timeline problems it wasn’t possible to make this fix working in short time. Therefore, the consequences are quite down-to-earth: For this application you have to use a smart browser (Firefox, for example) or rather the IE9 isn’t supported.

After this experience I will try to use dialogues only if there is no other way, that means, if the customer really wants them. I hope that in one of the next versions (maybe 8.5.3) everything gets better =)

UPDATE 2011/15/11:We could localize the problem. In fact, it is only one small CSS-Rule, called: “filter: progid:DXImageTransform.Microsoft.Aplpha(Opacity=0);”
Unfortunately we didn’t manage to remove this rule, so far. Somewhere deep in the code, it seems, it is added manually and we can’t do anything to prevent that.

UPDATE 28.03.2012: In Notes 8.5.3 and the new Dojo version it seems to work fine.

%d bloggers like this: