Jsf 2 显示加载状态
在我使用JSF2.0+Richfaces3.3.3的示例应用程序中。 我想显示所有a4j动作的加载状态 这意味着,当我单击按钮时,将在模式面板中显示加载状态。Jsf 2 显示加载状态,jsf-2,richfaces,loading,Jsf 2,Richfaces,Loading,在我使用JSF2.0+Richfaces3.3.3的示例应用程序中。 我想显示所有a4j动作的加载状态 这意味着,当我单击按钮时,将在模式面板中显示加载状态。 否则,当我单击按钮时,显示加载状态,同时在完成该过程之前不再执行a4j操作。 完成该过程后,我执行其他操作或单击同一按钮 在下面的示例代码中,我显示了按钮操作的加载状态。但我可以在加载期间多次单击同一按钮 <f:view> <html> <head> <met
否则,当我单击按钮时,显示加载状态,同时在完成该过程之前不再执行a4j操作。
完成该过程后,我执行其他操作或单击同一按钮 在下面的示例代码中,我显示了按钮操作的加载状态。但我可以在加载期间多次单击同一按钮
<f:view>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h:form id="sampleForm" binding="#{Sample.initForm}">
<a4j:commandButton value="Sample"
action="#{Sample.sampleButtonAction}"/>
<a4j:status>
<f:facet name="start">
<h:graphicImage value="ai.gif" alt="ai"/>
</f:facet>
</a4j:status>
</h:form>
</body>
</html>
</f:view>
所以我需要在加载期间防止任何操作
<f:view>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h:form id="sampleForm" binding="#{Sample.initForm}">
<a4j:commandButton value="Sample"
action="#{Sample.sampleButtonAction}"/>
<a4j:status>
<f:facet name="start">
<h:graphicImage value="ai.gif" alt="ai"/>
</f:facet>
</a4j:status>
</h:form>
</body>
</html>
</f:view>
Sample.java
package myapp.beans;
import javax.faces.component.html.HtmlForm;
public class Sample
{
private HtmlForm initForm;
public String sampleButtonAction()
{
System.out.println("Sample Button assigned....");
for(int i=1; i<=10; i++)
{
try
{
Thread.sleep(1000);
}
catch (InterruptedException ex)
{
System.out.println("Exception occured....");
}
}
return null;
}
public HtmlForm getInitForm(){
return initForm;
}
public void setInitForm(HtmlForm initForm){
this.initForm = initForm;
}
}
打包myapp.beans;
导入javax.faces.component.html.HtmlForm;
公共类样本
{
私有htmlforminitform;
公共字符串sampleButtonAction()
{
System.out.println(“指定的样本按钮”);
对于(inti=1;i试试这个
<h:form id="sampleForm" binding="#{Sample.initForm}">
<a4j:commandButton value="Sample" action="#{Sample.sampleButtonAction}"/>
<a4j:status
onstart="javascript:Richfaces.showModalPanel('progressWaitModalPanel');"
onstop="javascript:Richfaces.hideModalPanel('progressWaitModalPanel');">
</a4j:status>
<rich:modalPanel id="progressWaitModalPanel" autosized="true" moveable="true" >
<h:graphicImage value="ai.gif" alt="ai"/>
</rich:modalPanel>
</h:form>