2014-10-17 67 views
0

如何实用地添加“获取数据”之类的进度信息。当数据被获取时,我需要在空白页面上显示这条消息。我是ADF的新手,所以如果它是非常基本的东西,请原谅我。我无法在网上找到它。进度信息

回答

2

你可以在你的页面或pagefragment中使用javascript。我的例子使用页面片段,所以弹出窗口的ID必须包含区域。如果您在查找正确的ID时遇到问题,可以从任何浏览器查看它,使用View Source,然后搜索您输入的名称(在本例中为splashPopup)。

<af:resource type="javascript"> 
     function enforcePreventUserInput(evt) { 
      var popup = AdfPage.PAGE.findComponentByAbsoluteId('pt1:r1:0:splashPopup'); 
      if (popup != null) { 
       AdfPage.PAGE.addBusyStateListener(popup, handleBusyState); 
       evt.preventUserInput(); 
      } 
     } 

     function handleBusyState(evt) { 
      var popup = AdfPage.PAGE.findComponentByAbsoluteId('pt1:r1:0:splashPopup'); 
      if (popup != null) { 
       if (evt.isBusy()) { 
        popup.show(); 
       } 
       else if (popup.isPopupVisible()) { 
        popup.hide(); 
        AdfPage.PAGE.removeBusyStateListener(popup, handleBusyState); 
       } 
      } 
     } 
    </af:resource> 

pageFragment内部的弹出窗口。它显示一个简单的旋转圈gif动画。如果你需要在谷歌上,你可以找到许多其他的动画。

<af:popup id="p1" contentDelivery="immediate"> 
        <af:dialog id="d2" type="none" closeIconVisible="false" title="Loading"> 
         <af:panelGroupLayout id="pgl5" layout="vertical" halign="center"> 
          <af:image source="/images/loading.gif" shortDesc="Loading data..." id="i1"/> 
         </af:panelGroupLayout> 
        </af:dialog> 
</af:popup> 

现在,我想你会希望在按下按钮或图像链接后,在长时间运行的查询或其他长时间运行的过程中显示弹出窗口。为此,您必须在组件上定义一个clientListener,它使用上面定义的javascript方法。

<af:commandImageLink text="Test LongRunning Query" id="cil1" icon="/icons/excel.jpg" 
             action="#{myBean.doStuff}" 
         <af:clientListener method="enforcePreventUserInput" type="action"> 
         </af:clientListener> 
</af:commandImageLink> 
1

如果你有一个长时间运行的方法调用,然后你可以调用在页面加载

<af:serverListener type="onloadEvent" 
         method="#{backingBeanScope.initBean.callMethod}"/> 
<af:clientListener type="load" method="triggerOnLoad"/> 
<af:resource type="javascript"> 
     function triggerOnLoad(event) 
     { 
      AdfCustomEvent.queue(event.getSource(), "onloadEvent", {},false); 
      return true; 
     } 
    </af:resource> 

该方法,然后使用自动进稿器状态指示灯来显示页面上的状态。

<af:panelStretchLayout id="psl1" startWidth="33%" endWidth="33%" 
            topHeight="33%" bottomHeight="33%"> 
      <f:facet name="bottom"/> 
      <f:facet name="center"> 
      <af:statusIndicator id="si1"/> 
      </f:facet> 
      <f:facet name="start"> 
      <af:panelGroupLayout id="pgl2"/> 
      </f:facet> 
      <f:facet name="end"> 
      <af:panelGroupLayout id="pgl3"/> 
      </f:facet> 
      <f:facet name="top"> 
      <af:panelGroupLayout id="pgl4"/> 
      </f:facet> 
</af:panelStretchLayout> 

请参阅这篇博客来回详情 Show status indicator for long running method calls - ADF