
Question:
I have a Xpage that takes too long to load. So the client ask me to do a loading indicator.
I searched and found XSP.startAjaxLoading()
, that I put in onClientLoad event of the Custom Control.
But now I don't know where should I put XSP.endAjaxLoading()
to make the loading screen go away.
I'tried to use in afterRenderResponse and beforeRenderResponse: view.postScript("XSP.endAjaxLoading()")
, since this comand is CSJS, but it doesn't work.
Thanks in advance.
Answer1:I think you want to put it in the onComplete event. That can be difficult to find. You typically need to use the outline control to find it.
I have a video demo on NotesIn9 that has an example on this.
<a href="http://www.notesin9.com/2016/02/19/notesin9-188-adding-a-please-wait-to-xpages/?unique=http%3A//www.notesin9.com/2016/02/19/notesin9-188-adding-a-please-wait-to-xpages/" rel="nofollow">http://www.notesin9.com/2016/02/19/notesin9-188-adding-a-please-wait-to-xpages/?unique=http%3A//www.notesin9.com/2016/02/19/notesin9-188-adding-a-please-wait-to-xpages/</a>
Answer2:Your attempt (view.postscript
) works only with full/partial updates and does not work for page loading.
You have used onClientLoad
- which is executed when your page is finished with loading. I guess you get ajax animation after a while and it won't stop.
You should make preload screen - very simple XPage which starts animation and does not care to turn it off. In onClientLoad
event redirect to your slow XPage. That will discard the animation.
I'd highly recommend using the Standby Dialog XSnippet <a href="https://openntf.org/XSnippets.nsf/snippet.xsp?id=standby-dialog-custom-control" rel="nofollow">https://openntf.org/XSnippets.nsf/snippet.xsp?id=standby-dialog-custom-control</a>. I use it as a standard in all XPages applications.
Answer4:I used this answer as solution: <a href="https://stackoverflow.com/a/35481981/5339322" rel="nofollow">https://stackoverflow.com/a/35481981/5339322</a><br /> I've saw it a few days ago, what made me think twice is that using this i should know what is doing my XPages to delay. I ran some tests and discovered what, and it was a call to a method in the afterRestoreView event, then I migrated it to onClientLoad event and used the solution in the answer above cited. But I'm afraid that I have to keep an eye on it, so if someone adds some code that delays in one of the another events of XPages I have to move it again, of course, if it's possible, if it's not, I'll figure it out something diferent.
Thanks for all the answers ans comments.