0

Am developing application in JSF. I have created t:commandlink that calls JavaScript method in onclick event, I have an action in same t:commandlink. That will trigger once onclick event complete. Before I used IE browser So, I used window.openmodaldialog('sample.xhtml', '_blank'); to open popup in javascript like below,

<t:commandlink onclick="openPopup()" action="#{samplebean.savedata()}"></t:commandlink>

Javascript code:

function openPopup(){
  window.showmodaldialog('sample.xhtml', '_blank');
  return true;
}

In above code 'openPopup' method wait until showmodaldialog to close. Now am migrating application to Chrome browser. So, I used window.open since window.showmodaldialog is deprecated in Chrome. What am facing issue here is openPopup method not waiting until popup to close. It's getting executed and t:commandlink action block get called. How to make openPopup method to wait until popup close.

user3410249
  • 161
  • 4
  • 14

1 Answers1

0

try to switch to oncomplete, instead of onclick

Subodh Joshi
  • 12,717
  • 29
  • 108
  • 202
WoAiNii
  • 1,003
  • 1
  • 11
  • 19
  • Action should call after javascript method complete. – user3410249 Feb 20 '20 at 06:08
  • If it's a matter of openPopup should be called only if there's not problem in savedata, you could try like [this](https://stackoverflow.com/questions/14401652/how-to-trigger-args-validationfailed-in-primefaces-oncomplete). You can also try to call openPopup server side, at the end of savedata function – WoAiNii Feb 25 '20 at 18:33
  • You're right but before 50 rep i can't post comment ^^, now I use them – WoAiNii Feb 26 '20 at 11:28