How to use target=“_blank” to open report in new window only if validation has not failed

后端 未结 2 969
醉梦人生
醉梦人生 2020-12-18 06:50

I have a report that needs to be opened in another tab, but only if the validation hasn\'t failed. In my case, the validation fails and the same page opens in another tab wi

2条回答
  •  甜味超标
    2020-12-18 07:33

    Luiggi has answered the POST matter. If the report is however available by a GET request, then there are other ways.

    1. Use window.open() in oncomplete.

      
          ...
          
      
      
    2. Or conditionally render a with window.open().

      
          ...
          
          
              window.open('reportURL');
          
      
      
    3. Or use PrimeFaces RequestContext#execute() with window.open().

      public void submit() { 
          // ...
          RequestContext.getCurrentInstance().execute("window.open('reportURL');");
      }
      

    The first way requires the URL to be already definied before submit, the latter two ways allows you to use a dynamic URL like so window.open('#{bean.reportURL}').

提交回复
热议问题