在JDeveloper中,创建一个project,点击一个按钮,弹出一个含有Ok/Cancle的对话框。步骤如下:
1. 创建一个view cotroller project,并且新建一个JSF page,将ADF Faces的Popup component拖放到hello.jspx的页面的form上,
2. 创建Dialog,则将Dialog拖放到Popup component上面。
3. 选中该hello.jspx,点击Design->Page Properties...生成一个managed bean:DialogManagedBean
4. 双击button “Click me...”,然后将DialogManagedBean的showMyDialog()注册为事件
5. showMyDialog()代码如下:
public String showMyDialog() {
// Add event code here...
RichPopup.PopupHints hinsts = new RichPopup.PopupHints();
p1.show(hinsts);
return null;
}
6. 设置Dialog的Behavior的DialogListener为DialogManagedBean的sayHello方法,代码如下:
public void sayHello(DialogEvent dialogEvent) {
// Add event code here...
if (dialogEvent.getOutcome() != DialogEvent.Outcome.ok) {
System.out.println("Hello, Cancle is clicked.");
} else {
System.out.println("Hello, Ok is clicked.");
}
}
运行结果如下:
参考:
【1】http://docs.oracle.com/cd/E12839_01/web.1111/b31973/af_dialog.htm
【2】http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_33/jdtut_11r2_33.html
【3】077.
Handling the af:dialog Ok and CANCEL buttons
http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html
【4】http://docs.oracle.com/cd/E23943_01/web.1111/b31973/af_dialog.htm#CHDCBBJJ