2011-03-04 28 views
2
<h:commandLink action="#{bean.action}" onclick="window.open('../note/note.faces', 'popupWindowName', 'dependent=yes, menubar=no, toolbar=no, height=450, width=700');"> 

在上面的代碼彈出窗口在操作完成之前打開時點擊鏈接。彈出窗口在操作之前打開

行動完成後可以打開嗎?

回答

2

只需將要執行的邏輯移動到操作的目標頁面即可。

首先拆下onclick

<h:commandLink action="#{bean.action}"> 

然後擴展您的Bean如下:

private boolean executed; 

public String action() { 
    executed = true; 
    return "targetpage"; 
} 

public boolean isExecuted() { 
    return executed; 
} 

最後顯示有條件基於#{bean.executed} JS代碼:

<h:panelGroup rendered="#{bean.executed}"> 
    <script type="text/javascript"> 
     window.open('../note/note.faces', 'popupWindowName', 'dependent=yes, menubar=no, toolbar=no, height=450, width=700'); 
    </script> 
</h:panelGroup> 
+0

我想把一個鏈接,並在上面的代碼提到的行動。 – venkat 2011-03-04 14:54:05

+0

你似乎誤解了我的答案。我已經改進了答案。 – BalusC 2011-03-04 14:58:51

+0

謝謝balu它正在工作。 – venkat 2011-03-04 15:21:37