Initiating JavaScript call from server side

前端 未结 1 852
别那么骄傲
别那么骄傲 2021-01-27 18:09

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 fr

相关标签:
1条回答
  • 2021-01-27 18:36

    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 = "window.open('"+actionUrl+"', 'popupWindow', 'dependent=yes, menubar=no, toolbar=no');";
    FacesContext cxt = FacesContext.getInstance();
    PartialViewContext partialCtxt = ctxt.getPartialViewContext();
    partialCtxt.getExecuteIds().add(javaScriptText); 
    
    0 讨论(0)
提交回复
热议问题