【发布时间】:2018-11-25 04:09:27
【问题描述】:
我在 adf 中有一个 jspx 页面,其中包含一个“命令链接”,单击命令链接时,会通过“showPopupBehaviour”的定义属性打开一个弹出窗口。
但我想在单击 CommandLink 时验证某些内容,如果验证返回 True,则只有弹出窗口应该打开,否则如果在验证期间返回 False,则会出现相关消息。我对此进行了探索,并尝试使用以下代码以编程方式调用 Popup,但没有成功,甚至在单击 CommandLink 时也没有打开任何弹出窗口。
下面是我尝试过的代码:
/* Below method "showPopup_aug" is invoked through actionListener of CommandLink */
public void showPopup_aug(ActionEvent evt_popup) {
System.out.println("entered in showPopup_aug method");
RichPopup popup_aug = (RichPopup)JSFUtils.findComponentInRoot("pop_aug");
System.out.println("Popup_id="+popup_aug.getId());
/*
//pop_aug.PopupHints hints_aug = new RichPopup.PopupHints();
RichPopup.PopupHints hints_aug = new RichPopup.PopupHints();
popup_aug.show(hints_aug);
System.out.println("Popup-Aug opened");
*/
System.out.println("before calling showPopup method");
showPopup(popup_aug, true);
System.out.println("Popup-Aug opened");
}
下面的方法“showPopup”被调用以根据从“showPopup_aug”方法接收的参数打开一个弹出窗口:
public static void showPopup(RichPopup pop, boolean visible) {
try {
System.out.println("entered in showPopup code");
FacesContext context = FacesContext.getCurrentInstance();
if (context != null && pop != null) {
//String popupId = pop.getClientId(context);
String popupId = pop.getId();
System.out.println("ClientID of popup="+popupId);
if (popupId != null) {
System.out.println("Client PopupID is not null");
StringBuilder script = new StringBuilder();
script.append("var popup = AdfPage.PAGE.findComponent('").append(popupId).append("'); ");
if (visible) {
script.append("if (!popup.isPopupVisible()) { ").append("popup.show();}");
} else {
script.append("if (popup.isPopupVisible()) { ").append("popup.hide();}");
}
ExtendedRenderKitService erks = Service.getService(context.getRenderKit(), ExtendedRenderKitService.class);
erks.addScript(context, script.toString());
}
}
System.out.println("completion of showPopup code");
}
catch (Exception e) {
System.out.println("exception occured in showPopup code="+e.getMessage());
throw new RuntimeException(e);
}
}
我想在 ADF 应用程序中打开 adf Popup 之前执行验证或操作。
【问题讨论】:
-
请阅读Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 总结是这不是解决志愿者的理想方式,并且可能会适得其反。请不要将此添加到您的问题中。
-
我认为stackoverflow.com/questions/12460572/…(虽然是与 PrimeFaces 相关的 Q/A)包含您可以使用的有价值的参考资料。
-
以上代码有什么问题,可以根据showPopup_aug方法中的验证逻辑有条件地调用showPopup!
标签: oracle jsf oracle-adf