2011-05-10 33 views
1

我使用彈出窗口代碼認證,在這裏只以下組件:彈出窗口 - 執行操作並關閉

<h:inputText value="#{bean.masterKey.code}" /> 
<h:commandButton action="#{bean.checkMaster}" value="OK" type="submit"/> 

按鈕調用方法CHECKMASTER(),它設置的布爾變量真或假

public void checkMaster(){ 
    if (findMasterKey(masterKey.getCode())) Settings.ONCOST = true; 
    else Settings.ONCOST = false; 
} 

但是我想在執行動作(每次按下按鈕)後關閉彈出窗口。

但不知道如何..你能幫我嗎?

更新:

public static boolean findMasterKey(String key) 
{ 
    Session session = DaoSF.getSessionFactory('R').openSession(); 
    Criteria criteria = session.createCriteria(MasterType.class); 
    criteria.add(Restrictions.eq("code", key)); 
    MasterType foundMT = (MasterType)criteria.uniqueResult(); 

    if (foundMT != null) return true; 
    else return false; 
} 

回答

2

後執行行動瀏覽這個網頁的一些頁面說Foo

上的Foo頁面加載執行JavaScript的windows.close()

+0

哦,感謝快速回復。你能告訴我怎麼樣嗎?我沒有太多經驗。或者沒有一些更優雅的解決方案使用commandbutton的onclick參數?例如調用checkMaster()方法使用javascript函數和類似self.close()? – gaffcz 2011-05-10 12:10:47

+0

這一個更合適。考慮到在執行你的動作的時候會出現一些異常,所以用戶永遠不會知道它。在這種情況下,它應該得到妥善處理 – 2011-05-10 12:12:24

+0

啊哈,我現在明白了。使用faces-config.xml是實際的xhtml重定向到foo.xhtml,並通過。真的行!謝謝你,Jigar! – gaffcz 2011-05-10 12:26:26