I have a jspx page in adf containing a "Command Link" and on click of Command Link, a popup opens through defined properties of "showPopupBehaviour".
But I want to validate something on click of CommandLink and if validation return True then only the Popup should open, otherwise a relevant message will appear if it return False during validation. I explored about it and tried following code to invoke Popup programmatically but not get success in it and not even any popup open on click of CommandLink.
Below is code which I have tried :
/* 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");
}
Below method "showPopup" is invoked to open a popup based on parameters received from "showPopup_aug" method:
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);
}
}
I want to perform a validation or action before opening of adf Popup in ADF application.