ADF中使用Popup

來源:互聯網
上載者:User

 

概述

本文主要描述在Oracle ADF中使用Popup,利用showPopupBehavior,popup與dialog可以方便地實現。

需求

1、由按鈕觸發彈出Popup

2、第一個Popup中提示是否確定(Confirmation),如果確定,則進而彈出提示操作成功的Popup(Tip)

實現

1、建立ADF應用 
2、在ViewController項目中建立名為main.jspx的新頁面,在該頁面中添加Button 
3、在main.jspx頁面中添加popup,並在popup中嵌入dialog,由於該popup的作用是提示使用者進行操作確認,因此在Title中填如“Confirmation”,Type類型選擇為“okCancel”

 

4、在該Dialog中添加OutputText,提示使用者確認 
5、為該Dialog添加dialogListener,根據使用者點擊不同的按鈕(ok or cancel)以觸發不同的事件

6、在該dialogListener()方法中添加如下代碼:

public void dialogListener(DialogEvent dialogEvent) {<br /> if (dialogEvent.getOutcome() == DialogEvent.Outcome.ok) {<br /> FacesContext facesContext = FacesContext.getCurrentInstance();<br /> ExtendedRenderKitService extendedRenderKitService =<br /> Service.getRenderKitService(facesContext, ExtendedRenderKitService.class);<br /> String script = "var popup;popup = AdfPage.PAGE.findComponent('" + "p2" + "');popup.show();";<br /> extendedRenderKitService.addScript(facesContext, script);<br /> } else if (dialogEvent.getOutcome() == DialogEvent.Outcome.cancel) {<br /> //Nothing to do here...<br /> }<br />} 

7、完成了邏輯添加之後,繼續在main.jspx頁面中添加popup,以提示操作成功。這裡Title為“Tip”,Type為“ok”

 

8、在步驟2中建立出的Button中添加showPopupBehavior,設定其popupId為第一個添加的popup的id,即p1

9、全部布局完成之後的頁面Structure應為:

10、儲存應用,運行並查看結果

頁面運行:

點擊該Button:

點擊OK:

 

本文轉自Oracle Seeker:http://oracleseeker.com/2009/11/10/adf_popup_dialog_dialoglistener/

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.