on 08-05-2008 12:54 AM
I have a pretty lengthy iCommand that's being executed in the background when an HTML button is clicked. The users would like to see the mouse cursor become an hourglass instead of seeing an alert pop up. My block of code looks something like this:
function executeQuery()
{
window.document.body.style.cursor = "wait"; // function used for cursor to become an hourglass
execute iCommands here......
.
.
.
window.open();
window.document.body.style.cursor = "default"; // cursor becomes a regular pointer again.
}
The only problem is that the cursor doesn't turn at all (although it does work fine WHEN the Page_Load Function is executed (and querying upon loading of the page), even when the iCommands are taken a couple minutes to query. Is there something that Im doing wrong?
Any feedback and/or help would be greatly appreciated! Thank you!
Or if feasible with your design, you could use an animated GIF.
Now because the iCommand execution is taking sometime even the image kind of freezes , but in my experience , that is always a better visual approach to make the end user aware of query processing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you all for your help! I have done the following:
Page_Load()
{
hourglass()
executeLengthyQuery()
disable hourglass()
}
which for the most part seems to work EXCEPT for when the mouse cursor is on a Grid with the "AllowSelection" property enabled. Then it becomes a hand for the majority of the time until I wiggle my mouse cursor in the <BODY> of the document. Then the hand will somewhat toggle to an hourglass until it falls upon a grid item.
I have tried the Animated GIF but it seems to open up RIGHT as before the query is done. Any new thoughts or suggestions?
Help is greatly appreciated as always! Thank you!
I'll repeat myself: If you want something to be asynchronous, you'll need to MAKE it asynchronous!
Use the XmlHttpRequest object to invoke the Illuminator or Runner servlet, and do whatever processing you need to update the UI as the XmlHttpRequest object changes state.
Google "AJAX" and you'll find plenty of examples on how to do this...
Rick
Hi there,
I have to say that I do like the AJAX approach. I would also like to see an optional "Please Wait" message in the MII applets while they are refreshing.
I have done something simpler as in my case it really is synchronous processing as the user shouldn't do anything until after it is done.
As you experienced the cursor style on the body doesn't play well with applet. A more browser friendly approach would be to hide content and show a message or animated GIF while the processing is running, then show the content and hide the message/GIF when it was done. I ran into the a similar issue with the message not showing "Please wait". The trick is to put a "pause" in the javascript to get the message (or GIF) to render before starting the processing, set....Timeout(...);
Here is what I did. I did not have a GIF, just a message span that was always displayed with appropriate text.
.......
OK, so there is still a problem posting javascript. Give me your email if you want the code. amy.smith at haworth.com
.......
--Amy Smith
--Haworth
Does this post OK?
Have to put non-code in here as there is an issue showing javascript on this forum, even within a code block!
functionnnn changePlant
Message to user
document get ElementById('msgSpan') innerText ==== 'Please wait'
Disable buttons
document get ElementById ('plantButton') disabled ==== true
The div with the applet grid get hidden while processing
document get ElementById ('prodOrdsDiv') style visibility ==== 'hidden';
Update the applet - using setTimeout so the message will render before the applet loads
set Timeout('refreshApplet();', 30)
functionnnnnn refreshApplet
Get the plant number
var newPlant ==== document get ElementById('plant') value
var prodOrdsQuery ==== document ProdOrds get QueryObject()
prodOrdsQuery set Param(1,newPlant)
Refresh the applet
document ProdOrds re fresh()
Cleanup
document get ElementById('msgSpan') inner Text ==== 'Plant ' + newPlant
document get ElementById('prodOrdsDiv') style visib ility ==== ''
document get ElementById('plantButton') value ==== 'Change Plant'
document get ElementById('plantButton') disabled ==== false
Edited by: Amy Smith on Aug 12, 2008 11:18 AM
Hi,
To call the function by using FirstUpdateEvent :
Define a global variable:
var vApplet=0;
function checkApplet()
{
vApplet = vApplet+1;
if(vApplet ==1)
{
executeQuery();
}
else
{
}
}
checkApplet() will check your applet is loaded fully or not.
If it is loaded fully, it will call executeQuery().
function executeQuery()
{
window.document.body.style.cursor = "wait"; // function used for cursor to become an hourglass
execute iCommands here......
.
.
.
window.open();
window.document.body.style.cursor = "default"; // cursor becomes a regular pointer again.
}
Then call checkApplet() in your iCommand Applet like this:
At the end of applet
<PARAM NAME="FirstUpdateEvent" VALUE="checkApplet">
Hope this will help you.
Thanks,
Manisha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Manisha,
For your benefit and the rest of the forum, the iCommand has never supported the FirstUpdateEvent. This is only supported by applets that run their underlying query template by default (which the iCommand does not).
Please discontinue the erroneous and misleading postings. People post their questions here for insight and answers to their problems, not for random guesswork.
Regards,
Jeremy
I completely agree, Jeremy! Misleading suggestions can cause other users countless hours of wasted time and effort!
On the topic of how to do this, I would highly recommend using an AJAX approach instead of the iCommand applet in this case. The first "A" in AJAX is "asynchronous", which allows the application developer to do any type of processing to handle the pending request. In this case, you could use the XmlHTTPRequest object to invoke either the Illuminator servlet or the Runner servlet, as needed.
Rick
Hi,
Your problem is if iCommand applet is taking couple of minutes to execute, then this code is not working?
If my understanding is right,then instead of calling this function on page load you need to call by using FirstUpdateEvent.
This will ist check applet is loaded fully or not.If it is loaded then this code will be executed.If it is not loaded,then it will wait to load fully and then this code will be executed.
Hope this will help you.
Thanks,
Manisha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
3 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.