Reputation: 2087
I have an block of SSJS that does a fair bit of work copying creating a database and then copying a bunch of documents into it the basic structure is:
try{
getComponent("waitDialog").show(null);
// do stuff
}catch(e){
// do the error stuff
}finally {
getComponent("waitDialog").hide(null);
}
The button that executes this code does a full refresh When I click the button the Dialog comes up and the background code executes but when it hits getComponent("waitDialog").hide(null); it does not take the dialog down. I know that it gets to the finally because I have an output to the server console at that point. I use a dialog in other places and the getComponent().hide(null) works in them, but I in those cases I close the dialog from a button on the dialog, but I don't want to do that here. Also I would like to remove the "X" for the user to close the the dialog. Or is there a better way to do this sort of thing
Upvotes: 0
Views: 70
Reputation: 15729
I like this code for adding a standby control to all pages http://openntf.org/XSnippets.nsf/snippet.xsp?id=standby-dialog-custom-control. The advantage is it works then on all buttons, links etc., without adding anything to the eventHandlers.
Extension Library demo database, the page for loading the data into the database, shows how to add a Loading... message.
Upvotes: 2
Reputation: 1665
From the sounds of it, you are trying to show, then hide the dialog, all from the server, within one round trip. You can't do this. The dialog show and hide needs to be sent back to the browser in order to make UI changes, and that only happens once the refresh completes.
In this case I would expect you to get unexpected results like you are. If I thought about it logically, I would think you never would see the dialog, but I'd have to trace the backend code to see.
My suggestion would be to do a partial refresh, and in the onStart of the refresh, show an indicator that something is processing, then in the onComplete (and onError) remove the indicator. I also wouldn't use a dialog, for the very reason you mention (it enables the user to interact with the UI. I would look into some other form of progress indicator. For example, OpenNTF has a couple available if you search for "Partial Refresh" -> http://openntf.org/main.nsf/projects.xsp?query=partial%20refresh
Upvotes: 1