3

在用户的操作之后,我有两个相当连续的 ajax 请求,我通过<p:ajaxStatus>. 但是在它们之间,客户端发生了一些事情(不需要用户操作),显示 ajax 状态指示有一点中断。

有没有办法缩小这个差距?

更新:
我尝试了 KidTempo 的提议,使用另一个<p:remoteCommand>来执行async=trueAjax 请求,actionListener它现在似乎可以工作:

public void sleep(ActionEvent ae) throws InterruptedException{
    setAddressProcessingFinished(false);
    Thread thread = Thread.currentThread();
    while(addressProcessingFinished == false){
        thread.sleep(1000);
    }
}
4

1 回答 1

1

Have you looked at async=true ajax requests? (so the other ajax requests can run at the same time)

You could have an ajax request that sleeps until your second ajax request finishes. I think the ajaxStatus indication should then be active throughout.

sleepyAjax (until bean.finished==true)
|
|  yourAjax_1
|  yourAjax_2 (set bean.finished = true)
V
sleepyAjax Finished!

note: haven't tried this, it may not work this way but I'd be interested to know if it does...

于 2013-07-29T11:35:45.530 回答