Larry,
If you have time and interest I'm wrestling with the asynchronous nature of javascript and the problems introduced with the posting of an EXT.JS web form to get and validate the user name and password.
Using the code below I raise the following form but have two problems. The form is not active and seems to be hidden behind the Loading div?? how can I turn off the loading widget and is it plausible that the form is inactive because it is behind the loading div.
Anyway - here is my implementation of the code:
index.html, body:
( function waitForAPI() {
if (typeof require === 'undefined') {
if (window.console) {
console.log('Waiting for API to be loaded.');
}
setTimeout(waitForAPI, 100);
return;
}
else
{
validateCredentials();
}
function validateCredentials() {
require([
'dojo/aspect',
'dojo/Deferred',
'jimu/utils'],
function (aspect, Deferred, jimuUtils) {
aspect.around(jimuUtils, 'createWebMap', function(originalMethod) {
return function(portalUrl, itemId, mapDiv, options) {
var mapDeferred = new Deferred();
var authDefer = new Deferred();
var authResult = null;
// Set up the authorization deferrer:
authDefer.then(
//Callback after resolution of the deferrer
function (authResult) {
//ServiceStatus < 0 indicates the call to the service is incomplete. 0 indicates Cancel, > 0 indicates the service has executed, See Result for success or failure)
//authResult = { ServiceStatus: N, ServiceResult: "STRING", bIsAuth: Bool };
if (authResult.bIsAuth) {
originalMethod.call(jimuUtils, portalUrl, itemId, mapDiv, options).then(function(deferred) {
mapDeferred.resolve(deferred);
return;
});
}
else
{
map.remove();
mapDeferred.reject();
window.location.assign("http://localhost/wab1/NotAuthorized.html");
confirm('Credentials not Valid');
}
}
);
// Call this with authDefer and wait for resolution
r5AuthMod.Authenticate("EPAOSC_Token", authDefer);
return mapDeferred;
//return authDefer;
};
});
});
}
})();