gpt4 book ai didi

jsf-2 - 屏蔽整个页面

转载 作者:行者123 更新时间:2023-12-02 08:31:30 25 4
gpt4 key购买 nike

当我更改页面(page1 到 page2)时存在一些延迟,可以单击其他按钮并运行这些操作。所以我想在加载下一页的等待时间内阻止该页面,我该怎么办?

我使用 jsf2 和 primefaces。

此时已经测试了 blockUI 和 blockUI-extensions -> 不工作

最佳答案

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

试试这个。这是工作。

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

<?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

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();
}
}
}

关于jsf-2 - 屏蔽整个页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26304582/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com