2012-02-03 52 views
0

在我的示例应用程序中使用JSF2.0 + Richfaces3.3.3。 我想显示所有a4j动作的加载状态。显示载入状态

这意味着,当我点击按钮,然后在模态面板中显示加载状态。
否则,当我点击按钮,显示加载状态,并在同一时间没有更多的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> 

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

帮助我, 在此先感谢

回答

0

试试这个

<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> 
1
<a4j:status 
    onstart="#{rich:component('procesoEsperaPopupPanel')}.show(); return false;" 
    onstop="#{rich:component('procesoEsperaPopupPanel')}.hide(); return false;"> 
</a4j:status> 

<rich:popupPanel id="procesoEsperaPopupPanel" autosized="true" moveable="true"> 
    <h:graphicImage name="ai.gif" alt="ai"/> 
</rich:popupPanel>