Initiating JavaScript call from server side

I was reading this and about halfway down is a tactic to call a JavaScript function from the server side. Works almost perfectly but I would like to prevent the original page from reloading. Tried to do this with an <a4j:commandLink> but then the popup page wasn't appearing at all. Any ideas on how to achieve this?



Until you post the code you're running, you might not get a specific answer why the <a4j:commandLink/> is failing

Without any additional libraries however, a hacky way to execute client-side code is to use the PartialViewContext. The mechanism is similar to what that tutorial recommends, only that you don't need any utility to achieve the same effect.

String javaScriptText = "'"+actionUrl+"', 'popupWindow', 'dependent=yes, menubar=no, toolbar=no');";
FacesContext cxt = FacesContext.getInstance();
PartialViewContext partialCtxt = ctxt.getPartialViewContext();


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.