2012-02-03 53 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>