封锁整个页面 [英] Block entire page

查看:125
本文介绍了封锁整个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我更改页面(从第1页到第2页)时,存在一些延迟,可以单击其他按钮,然后执行这些操作.因此,我想在等待加载下一页的页面期间屏蔽该页面,我该怎么办?

When I change the page (page1 to page2) exists some delay and it is possible to click other buttons and these actions go run. So I would like to block the page during the waiting time for loading the following page, how do I?

我使用jsf2和primefaces.

I use jsf2 and primefaces.

这时已经测试了blockUI和blockUI扩展->不起作用

At this time already tested blockUI and blockUI-extensions -> not work

推荐答案

您应该告诉我们.为什么p:blockUI不起作用?

You should tell us. Why p:blockUI is not work?

尝试一下.是工作.

page1.xhtml

page1.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <f:facet name="first">
            <meta http-equiv="Content-Type" 
                  content="text/html; charset=UTF-8" />
            <meta name="viewport" 
                  content="user-scalable=no, 
                  width=device-width, 
                  initial-scale=1.0, 
                  maximum-scale=1.0"/>
        </f:facet>

        <title>page1</title>
    </h:head>

    <h:body id="bodyView">
        page1
        <h:form id="form1">
            <p:editor id="editor" 
                      widgetVar="editorWidget" 
                      width="600" />
        </h:form>
        <h:form id="form2">
            <p:blockUI block=":bodyView" 
                       widgetVar="bui"/>
            <p:commandButton id="redirect" 
                             value="go to page2" 
                             onclick="PF('bui').show();"
                             actionListener="#{blockView.redirect}"/>
        </h:form>
    </h:body>
</html>

page2.xhtml

page2.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <f:facet name="first">
            <meta http-equiv="Content-Type" 
                  content="text/html; charset=UTF-8" />
            <meta name="viewport" 
                  content="user-scalable=no, 
                  width=device-width, 
                  initial-scale=1.0, 
                  maximum-scale=1.0"/>
        </f:facet>

        <title>page2</title>
    </h:head>

    <h:body>
        <h:form>
            page2
        </h:form>
    </h:body>
</html>

MangedBean

MangedBean

import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

/**
 *
 * @author Wittakarn
 */
@ViewScoped
@ManagedBean(name = "blockView")
public class BlockView implements Serializable{
    public void redirect(ActionEvent event){
        try {
            Thread.sleep(4000);
            FacesContext.getCurrentInstance().getExternalContext().redirect("page2.xhtml");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

这篇关于封锁整个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆