ADF Facesのポーリングについて

ADF Facesのpollコンポーネントは、定期的にサーバーをポーリングするために使用されます。参照可能オブジェクトはレンダリングしません。ポーリングの時間間隔はinterval属性にミリ秒単位で設定します。このコンポーネントは、指定の時間間隔が経過した後にポーリング・イベント(oracle.adf.view.faces.event.PollEvent)をトリガーします。ポーリング・リスナーは、このポーリング・イベントに応じて、モデルを更新したりダイアログを起動することができます。

たとえば、pollコンポーネントを使用すると、次のように、3秒後または10分ごとに1回、プログラムによってダイアログを起動できます。

  <af:poll pollListener="#{myBean.poll}" interval="3000"/>    
  <af:poll pollListener="#{myBean.sessionAboutToExpire}" interval="600000"/>     

pollListener属性は、ポーリング・リスナーにバインドするメソッドを指定します。このリスナーは、次の両方の例では、AdfFacesContext.launchDialog()メソッドを使用し、プログラムによって(JSFナビゲーション・ルールを使用せずに)ダイアログを起動しています。

...
public void poll(PollEvent event)
{

  FacesContext context = FacesContext.getCurrentInstance();
  UIViewRoot root = context.getApplication().getViewHandler().createView(
                      context, "/simpleDialog.jspx");
  // Launch a dialog with a call to AdfFacesContext
  AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();
  afContext.launchDialog(root, null, event.getComponent(), true, null);

  // Stop the poll from running
  event.getComponent().setRendered(false);

}
...    
...
public void sessionAboutToExpire(PollEvent event)
{

  FacesContext context = FacesContext.getCurrentInstance();
  // Create the dialog
  UIViewRoot ViewHandler viewHandler = context.getApplication().getViewHandler();
  UIViewRoot dialog = context.createView(context, "/sessionExpiring.jspx");

  HashMap properties = new HashMap();
  properties.put("width", new Integer(250));
  properties.put("height", new Integer(150));

  AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();
  afContext.launchDialog(dialog,
                         null, // no particular parameters
                         null, // not launched from any component
                         true, // show it in a dialog
                         properties); 

}
...    

注意: モデル・ダイアログは、pollコンポーネントと同じページにあるコンポーネント(selectInputColorcommandButtonなど)から起動されると仮定しています。この状況が発生すると、ADF Facesは、ユーザーがダイアログを閉じるまでポーリングを中断します。pollコンポーネントのデモは、「ADF Facesのデモ・ファイルについて」を参照してください。

pollコンポーネントは、他のコンポーネントのリフレッシュにも使用できます。pollに指定された時間間隔が経過した後、ADF Facesは、partialTriggers属性がpollコンポーネントのIDに設定されているコンポーネントを再度レンダリングします。pollコンポーネントは、部分ページ・レンダリングを自動的に使用します(使用可能な場合)。pollをコンポーネントのトリガーとして使用する例は、「プログレス・バーについて」を参照してください。


ADF Facesでの部分ページ・レンダリングのサポートについて
ADF Facesのダイアログ・フレームワークについて