1
我面臨使用clientListener處理disclosureEvent的問題。我試圖在用戶導航離開panelTabbed中的選項卡時顯示Ok/Cancel彈出窗口。af:panelTabbed - 在選項卡切換時顯示彈出框的問題
下面是代碼:(這是設在甲骨文ADF代碼角完全相同的代碼)
<af:resource type="javascript">
function alertTabSwitch(disclosureEvent){
var tab = disclosureEvent.getSource();
if(tab.getDisclosed()==false){
var popup = tab.findComponent('p1');
popup.show();
popup.setProperty("tabToOpen",tab.
disclosureEvent.cancel();
}
}
function handlePopupOkCancel(actionEvent){
var popupButton = actionEvent.getSource();
var butPressed = popupButton.getProperty('popupAction');
var dialog = popupButton.getParent();
var popup = dialog.getParent();
if(butPressed == 'OK'){
var tabToFindAndFocusOnString = popup.getProperty("tabToOpen");
if(tabToFindAndFocusOnString.length > 0){
var tab = AdfPage.PAGE.findComponentByAbsoluteId(tabToFindAndFocusOnString);
tab.setDisclosed(true);
actionEvent.cancel();
popup.hide();
}
}
else{
//close popup and stay on page
actionEvent.cancel();
popup.hide();
}
}
</af:resource>
<af:panelStretchLayout id="psl1">
<f:facet name="center">
<af:panelTabbed id="pt1">
<af:showDetailItem text="TAB 1" id="sdi1" disclosed="true" stretchChildren="first"
clientComponent="false">
First Tab
<af:clientListener method="alertTabSwitch" type="disclosure"/>
</af:showDetailItem>
<af:showDetailItem text="TAB 2" id="sdi2" stretchChildren="first" clientComponent="false">
Second Tab
<af:clientListener method="alertTabSwitch" type="disclosure"/>
</af:showDetailItem>
</af:panelTabbed>
<!-- id="af_one_column_stretched" -->
</f:facet>
<f:facet name="start">
<af:popup childCreation="deferred" autoCancel="disabled" id="p1" clientComponent="true"
contentDelivery="immediate">
<af:dialog id="d1" title="Tab Switch Alert" type="none">
<f:facet name="buttonBar">
<af:panelGroupLayout id="g1">
<af:commandButton text="OK" id="cb1" partialSubmit="true">
<af:clientAttribute name="popupAction" value="OK"/>
<af:clientListener method="handlePopupOkCancel" type="action"/>
</af:commandButton>
<af:commandButton text="CANCEL" id="cb2" partialSubmit="true">
<af:clientAttribute name="popupAction" value="CANCEL"/>
<af:clientListener method="handlePopupOkCancel" type="action"/>
</af:commandButton>
</af:panelGroupLayout>
</f:facet>
<af:outputText value="Do you really want to switch tabs?" id="ot1"
inlineStyle="font-size:medium; color:Red;"/>
</af:dialog>
<af:clientAttribute name="tabToOpen" value=""/>
</af:popup>
</f:facet>
</af:panelStretchLayout>
一切都被在客戶端完成。當我點擊一個選項卡時,首先爲選定的選項卡觸發「取消選擇」事件,並將該選項卡的公開值更改爲false。值改變後,偵聽器被調用。 所以在javascript中,點擊OK按鈕後再次顯示相同的選項卡。 如果在調用af:clientListener之前沒有更改該值,則不會出現此問題。
有人可以幫我嗎?
我已經在這裏更徹底地描述了這個問題。 https://forums.oracle.com/message/11227277#11227277
問候, Navaneet
一些測試代碼缺少,像popup.setProperty(」 tabToOpen」選項卡。 –