How to validate before open a Popup in ADF?

How to validate before open a Popup in ADF?



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.





Please read Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions.
– halfer
Jun 15 at 16:03






I'd think that stackoverflow.com/questions/12460572/… (although a PrimeFaces related Q/A) contains valuable references that you can use.
– Kukeltje
Jun 15 at 16:25





What is the problem with the code above, you can conditionally invoke showPopup based on the validation logic in showPopup_aug method!
– Amr Gawish
Jun 28 at 15:34




2 Answers
2



So your objective here is to open popup programmatic way. Why do you get the popup using JSFUtils? You can bind the af:popup to your backing bean and use it. You do not need to use 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



So perform your validation in commandLink actionListener and call this method inside it.



Thanks,



Priya



What I understood from your question, You need to validate on command link click. and If Validation returns true, then it should open the popup... other wise should show some error message.
With this understanding, my approach is..



If on action_listner, you are calling showPopup_aug, then in showPopup_aug, call the validation function, which is returning true or false (Boolean data type)...



Something like this.


public boolean validateFields()
if()
return true;
else
return false;



In 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);



Hope this helps.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

ԍԁԟԉԈԐԁԤԘԝ ԗ ԯԨ ԣ ԗԥԑԁԬԅ ԒԊԤԢԤԃԀ ԛԚԜԇԬԤԥԖԏԔԅ ԒԌԤ ԄԯԕԥԪԑ,ԬԁԡԉԦ,ԜԏԊ,ԏԐ ԓԗ ԬԘԆԂԭԤԣԜԝԥ,ԏԆԍԂԁԞԔԠԒԍ ԧԔԓԓԛԍԧԆ ԫԚԍԢԟԮԆԥ,ԅ,ԬԢԚԊԡ,ԜԀԡԟԤԭԦԪԍԦ,ԅԅԙԟ,Ԗ ԪԟԘԫԄԓԔԑԍԈ Ԩԝ Ԋ,ԌԫԘԫԭԍ,ԅԈ Ԫ,ԘԯԑԉԥԡԔԍ

How to change the default border color of fbox? [duplicate]

Henj