Overriding Servoy's default Loading... Ajax message

I had a client that really didn’t like the “Loading…” in the upper right. Some users don’t notice it, and they think the screen is frozen. There is the busy plugin, but as you all know, sometimes its a pain to run all functions through the busy plugin. So, below is a simple example of how to change the Loading… to something different. This shows how to change the message, and the location. In this example, we change “Loading…” to an animated spinner gif, and move it to the center of the screen. This works by adjusting the SPAN element that Servoy uses, so Servoy takes care of hiding and showing it.

Written in Servoy 6
Requires the WebClientUtils plugin

var js = 'function centerElem(elem) {\
	    var parent = window;\
	    elem.css({\
	    	"background-color": "transparent",\
	        "position": "absolute",\
	        "top": ((($(parent).height() - elem.outerHeight()) / 2) + $(parent).scrollTop() + "px"),\
	        "left": ((($(parent).width() - elem.outerWidth()) / 2) + $(parent).scrollLeft() + "px")\
	    });\
	}\
	centerElem($("#indicator"));\
	$("#indicator").html("<img src=\'http://www.nasa.gov/multimedia/videogallery/ajax-loader.gif\' />");'
	plugins.WebClientUtils.executeClientSideJS(js)

Note: for simplicity the code references the ajax-loader.gif on another website, but in your real code you should download the gif and host it in your Servoy ROOT/images directory, and modify the reference appropriately (/images/ajax-loader.gif).

Here is an example, as you can see the spinner in the middle of the screen.

In my solution setup, I generally only have one main form which contains tab panels, and I swab forms in and out of the tab panels in the navigation framework (so I never change the main form). So, in my case I only have to run this code once, onSolutionOpen. If you switch main forms, you may need to run it multiple times, or find a different approach (I haven’t tried it with other types of navigation)

Also, I’ve considered including something like this in the Busy plugin. Something like below:

plugins.busy.overrideLoadingMessage(pathToImageOrText, shouldCenter)

Data Sutra’s latest “busy” blocker:

[attachment=0]loading.png[/attachment]

Two demo servers to try it out on:

http://demo.data-sutra.com
http://europe.data-sutra.com

Excellent thanks Scott!

Scott,

WHOA! This is simply AWESOME! Thanks so much for sharing this! It should be the default… :D

Bob

Good news for you Bob: it is…

Some clarification: as of Servoy 7.1 the setting “servoy.webclient.blockinputonrequest” is enabled by default and shows a loading cursor instead of a loading indicator while communication with the server is taking place.

See SVY-4036 - replace “loading…” indicator with busy cursor

Paul,

That’s really great! It’s those “little” touches that make a HUGE difference in the product!

NICE WORK! :D

Bob

Paul,

Is this only when deployed on the application server? I’m still seeing the “Loading…” message (7.1.0). When I run the code above at startup, then it DOES have a spinner… is that maybe in an up-coming build or am I just doing it wrong? :wink:

In the example of Scott, in his code, he changes “Loading…” to the animated spinner gif from NASA (ajax-loader.gif). I supposed you can use instead any other image (such as the one that David is using for the CMS).

My question: does Servoy allows -or makes it easy for developers- the use of another image than the loading cursor that is now the default? Is it Servoy’s approach as flexible as the example code from Scott?

Thanks, Carlos