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
コンポーネントと同じページにあるコンポーネント(selectInputColor
やcommandButton
など)から起動されると仮定しています。この状況が発生すると、ADF Facesは、ユーザーがダイアログを閉じるまでポーリングを中断します。pollコンポーネントのデモは、「ADF Facesのデモ・ファイルについて」を参照してください。
poll
コンポーネントは、他のコンポーネントのリフレッシュにも使用できます。poll
に指定された時間間隔が経過した後、ADF Facesは、partialTriggers
属性がpoll
コンポーネントのIDに設定されているコンポーネントを再度レンダリングします。poll
コンポーネントは、部分ページ・レンダリングを自動的に使用します(使用可能な場合)。poll
をコンポーネントのトリガーとして使用する例は、「プログレス・バーについて」を参照してください。
ADF Facesでの部分ページ・レンダリングのサポートについて
ADF Facesのダイアログ・フレームワークについて
Copyright © 1997, 2007, Oracle. All rights reserved.