2014-02-20 112 views
0

我试图重定向到一个新的标签,这段代码应该是工作,但它重定向我在同一个页面JSF 2.0重定向到新的标签

XHTML页面

<h:form id="previewForm1" target="_blank"> 
     <p:commandButton value="Preview" action="#{executeJasper.printOnCriteria}" > 
      <f:setPropertyActionListener target="#{executeJasper.format}" value=".html"/> 
      <f:setPropertyActionListener target="#{executeJasper.listOnCriteria}" value="#{reports2.exportedWorkOrders}"/> 
      <f:setPropertyActionListener target="#{executeJasper.order_by_form}" value="detail_no"/> 
     </p:commandButton> 
    </h:form> 

 try { 
       System.out.println("Redirecting...."); 
       FacesContext.getCurrentInstance().getExternalContext().redirect(sHandler.getServerURL() + "VAS/faces/Downloads/" + folderName + "\\WorkOrderDetails_" + wOrder + format); 
      } catch (IOException ex) { 
       System.out.println("Output File: " + outputFile + " not found"); 
      } 

回答

0

可以实现两种方式重定向内豆你可以创建你的返回类型为字符串的方法,你可以返回XHTML页面像 和假设你想重定向to test1.xhtml

public String test() { 
//Do some operation 
     return test1; 

    } 

第一个可能是正确的,但你应该检查它是否正确。