【问题标题】:Show loading status显示加载状态
【发布时间】:2013-11-21 01:26:57
【问题描述】:

在我的示例应用程序中使用 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>

示例.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;
}
}

帮帮我, 提前致谢

【问题讨论】:

    标签: jsf-2 richfaces loading


    【解决方案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>
    

    【讨论】:

      【解决方案2】:

      试试这个

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-07-10
        • 1970-01-01
        • 1970-01-01
        • 2017-08-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多