如何确保 Liferay/ICEFaces 中的每次回发后都会调用 Javascript 函数?
我对 Liferay 和 ICEFaces 的经验很少。我需要构建一个 portlet,在每次回发发生时调用特定的 Javascript 函数。
事实上,当通过 AJAX 提交表单时,会出现加载屏幕并阻塞屏幕。当回发完成后,我需要将其取出并再次将控制权交给用户。
我尝试将 片段放入 portlet 的主体中,并且在首次加载页面时(没问题)以及在回发更改页面的 HTML 内容时成功执行。
问题是,当服务器不更改 HTML 时(即,搜索没有返回结果,您再次搜索,仍然没有结果),该函数不会再次执行。
即使我可以发布一些代码,我对构建 Web 应用程序的架构也知之甚少。我在这里提供的是我所掌握的所有信息。通过编辑 javascript 函数以在调用时发出警报,我发现了页面的行为。
你能帮我吗?
I have very little experience with Liferay and ICEFaces. I need to build a portlet that calls a specific Javascript function every time a postback occurs.
In fact, when the form is submitted through AJAX, a loading screen appears and blocks the screen. When the postback completes, I need to take it out and give control to user again.
I have tried to put the <script>
snippet in the portlet's body and it succeeds in executing when the page is first loaded (it's ok) and also when a postback changes the page's HTML content.
The problem is, when the server doesn't change the HTML (ie. a search returned with no result, you search again and you still get no results) the function is not executed again.
Even if I could post some code, I have very little idea of the architecture the web application is built on. What I gave here is all the information I have. By editing the javascript function to emit alerts when it's called I found the behaviour of the page.
Can you help me with that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过以下方法:
但是此解决方案适用于您发出的每个ajax请求,希望这可以帮助您。
Have you tried the following:
But this solution applied for every ajax request you made, hope this can help you.
我用一个奇怪的技巧和我想分享的随机数来制作它。
首先,在支持 bean 属性中,我创建了一个方法
,然后
“简单地”,ICEFaces 非常智能,它会在处理 AJAX 请求时检查 HTML 是否已被修改。此技巧与将随机数附加到 HTTP URL 以避免缓存非常相似。
I made it using a weird trick with random numbers I want to share.
First, in the backing bean property I created a method
and then
"Simply", ICEFaces is so smart it checks if the HTML has been modified or not when processing AJAX requests. This trick is very similar to appending a random number to HTTP URLs to avoid caches.