【问题标题】:Display a Loading/Splash Screen while a JSF page is being rendered?在呈现 JSF 页面时显示加载/启动屏幕?
【发布时间】:2013-05-31 17:00:12
【问题描述】:

我有一个 JSF 站点,其中一些数据项需要一段时间才能显示,因为要呈现的数据量很大。

我知道如何在按钮点击时使用 BlockUI 之类的东西来在执行操作或 AJAX 时显示等待消息。

但是,当我直接输入 URL 并转到页面时,我无法弄清楚如何触发类似的东西。当我使用 onload 或 onready 事件时,它几乎不会在显示页面之前闪烁消息。

有什么想法吗?

【问题讨论】:

    标签: jquery jsf-2 primefaces


    【解决方案1】:

    因为你没有提供任何关于你的代码

    When I use onload or onready events it barely flashes the message right before displaying the page.
    

    我假设你做对了。这个解决方案怎么样?服务器在后台 bean 中执行一些处理,而客户端查询服务器'如果他完成了'?

    服务器端:

    @YourScope (> @RequestScope)
    @ManagedBean
    public class MyBean {
    
      private boolean renderDone = false;
    
      @PostConstruct
      public void renderLotOfData() {
        renderDone = false;
        // do something which takes a long time here
        renderDone = true;
      }
    
      public boolean isRenderDone() {
        return this.renderDone;
      }
    
    }
    

    客户端:

    showMySplash(); // initial call
    
    function renderDoneBlockUi() {
      var renderDone = $('#renderDone').val();
      if (renderDone) {
        hideMySplash();
      } else {
        setTimeout(checkRenderDone, 1000);
      }
    }
    
    <h:inputHidden value="#{myBean.renderDone}" id="renderDone" />
    
    <p:remoteCommand name="checkRenderDone" update="renderDone" actionListener="#{myBean.renderDone}" autoRun="true" oncomplete="renderDoneBlockUi" />
    

    参考文献

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-05
      • 2014-02-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多