我在adf中有一个包含“Command Link”的jspx页面,点击Command Link后,弹出窗口将通过“showPopupBehaviour”的已定义属性打开。
但我想点击CommandLink验证一些内容,如果验证返回True,则只打开Popup,否则如果在验证期间返回False,则会出现相关消息。我探讨了它并尝试使用代码来以编程方式调用Popup但没有获得成功,甚至在点击CommandLink时都没有打开任何弹出窗口。
以下是我尝试过的代码:
final ConnectivityManager conman = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
final Class conmanClass = Class.forName(conman.getClass().getName());
final Field connectivityManagerField = conmanClass.getDeclaredField("mService");
connectivityManagerField.setAccessible(true);
final Object connectivityManager = connectivityManagerField.get(conman);
final Class connectivityManagerClass = Class.forName(connectivityManager.getClass().getName());
final Method setMobileDataEnabledMethod = connectivityManagerClass.getDeclaredMethod("setMobileDataEnabled", Boolean.TYPE);
setMobileDataEnabledMethod.setAccessible(true);
setMobileDataEnabledMethod.invoke(connectivityManager, enabled); // pass true or false
下面的方法调用“showPopup”来打开一个基于从“showPopup_aug”方法收到的参数的弹出窗口:
/* 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");
}
我想在ADF应用程序中打开adf Popup之前执行验证或操作。
答案 0 :(得分:0)
因此,这里的目标是打开弹出式编程方式。为什么使用JSFUtils弹出窗口?您可以将af:popup绑定到支持bean并使用它。您无需使用javascript。
private RichPopup myPopup ;//bound to the UI component
public void showOrHidePopup(RichPopup popup,Boolean visible){
if(visible){
RichPopup.PopupHints hints = new RichPopup.PopupHints();
myPopup.show(hints);
}
else{
myPopup.hide();
}
https://coderoar.blogspot.com/2018/08/oracle-adf-show-or-hide-popup.html
因此,请在commandLink actionListener中执行验证并在其中调用此方法。
谢谢
Priya
答案 1 :(得分:0)
我从您的问题中了解到,您需要在单击命令链接时进行验证。如果Validation返回true,则应该打开弹出窗口...否则,应该显示一些错误消息。 有了这种了解,我的方法就是..
如果在action_listner上,您正在调用showPopup_aug,然后在showPopup_aug中,调用验证函数,该函数返回true或false(布尔数据类型)...
这样的事情。
public boolean validateFields() {
if()
return true;
else
return false;
}
在showPopup_aug中,
public void showPopup_aug(ActionEvent evt_popup) {
if(validateFields())
{
showPopup(popup_aug);//defination given below
}
else
{
FacesMessage fm = new FacesMessage("Error Message");
fm.setSeverity(FacesMessage.SEVERITY_ERROR);
FacesContext fctx = FacesContext.getCurrentInstance();
fctx.addMessage(null, fm);
}
}
public void showPopup(RichPopup popup) {
RichPopup.PopupHints hint = new RichPopup.PopupHints();
popup.show(hint);
}
希望这会有所帮助。