Where should I use XSP.endAjaxLoading()?

倾然丶 夕夏残阳落幕 提交于 2019-12-12 04:21:45

问题


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.


回答1:


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.

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/




回答2:


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.




回答3:


I'd highly recommend using the Standby Dialog XSnippet https://openntf.org/XSnippets.nsf/snippet.xsp?id=standby-dialog-custom-control. I use it as a standard in all XPages applications.




回答4:


I used this answer as solution: https://stackoverflow.com/a/35481981/5339322
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.



来源:https://stackoverflow.com/questions/40427156/where-should-i-use-xsp-endajaxloading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!