简体   繁体   English

在完全加载之前,页面加载栏隐藏在jsf中

[英]Before fully loading page loading bar is hided in jsf

Actually I am getting loading bar but before page content get loaded loading bar is hided. 实际上我正在加载栏,但在页面内容加载之前,加载栏被隐藏。 I want loading bar until page is not loaded correctly. 我想要加载栏,直到页面未正确加载。

Below code I have used in layout.xhtml 我在layout.xhtml中使用的代码如下

 <li class="#{loginBean.subMenu eq 'Booking_History' ? 'active' : ''}">
          <p:commandLink rendered="#{loginBean.logedadmin or loginBean.logedagent}" action="#{bookingHistoryBean.showList}" value="Booking History"
                        immediate="true">
                        </p:commandLink>

java method java方法

public String showList() {
    startLoadingBar();
    status="All";
    noOfRecords=0;
    getList();
    searchBookingHistory();
    log.info("Loaded successfully");
    return "/pages/internalstackholders/bookinghistory.jsf?faces-redirect=true";
}

In bookinghistory.xhtml 在bookinghistory.xhtml

 <p:dialog widgetVar="statusDialog" id="statusbar" modal="true"
        showEffect="fade" showHeader="false" closable="false" width="250"
        resizable="false">
    <h:form>
      <center>
        <img src="#{request.contextPath}/resources/images/loading.gif" /><br />
        <b>Please wait...</b><br />
        <br />
      </center>
    </h:form>
  </p:dialog>

Any body having any suggestion. 任何有任何建议的机构。

You can try with below code it works for me onclick="statusDialog.start()" and oncomplete="statusDialog.close()" 你可以尝试下面的代码,它适用于我onclick =“statusDialog.start()”和oncomplete =“statusDialog.close()”

    <p:commandButton rendered="#{loginBean.logedadmin or loginBean.logedagent}" action="#{bookingHistoryBean.showList}" value="Booking History" immediate="true" async="true" onclick="statusDialog.start()" oncomplete="statusDialog.close()" />

<p:dialog widgetVar="statusDialog" id="statusbar" modal="true"
    showEffect="fade" showHeader="false" closable="false" width="250"
    resizable="false">
<h:form>
  <center>
    <img src="#{request.contextPath}/resources/images/loading.gif" /><br />
    <b>Please wait...</b><br />
    <br />
  </center>
</h:form>

I have found my answer.. 我找到了答案..

In layout.xhtml I have added below code inside body. 在layout.xhtml中,我在body中添加了下面的代码。

<div id="nonAjaxLoad">
    <img src="#{request.contextPath}/resources/images/loading.gif"/>
</div>

Then I have added script code. 然后我添加了脚本代码。

<script>
$(document).ready(function(){
    console.log("ready is called");
    //PF('statusDialog').hide()
    $('#nonAjaxLoad').hide();
});

$(window).bind('beforeunload', function() {
     console.log("bind is called");
    // PF('statusDialog').show()
    $('#nonAjaxLoad').show(); 
});
</script>

And I have added in css 我已经添加了css

#nonAjaxLoad {
width: 50px;
height: 50px;
position:absolute;
bottom: 50%;
right: 50%;
z-index: 999
}

Now loading bar is working correctly. 现在加载栏正常工作。 I took help from here . 我从这里接受了帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM