2017-05-04 196 views
0

當我點擊對話框中的yes按鈕後,重新加載頁面時出現問題。當我點擊yes按鈕(確認,所以可以刪除項目)後,我希望頁面刷新/重新加載,以便我可以看到當前項目。如何在對話框關閉後重新載入頁面/刷新頁面

這裏是我的代碼

<p:commandButton id="checkin" action="#{checkoutListBean.doCheckin(c.checkoutNumber)}" 
    value="Checkin" > 
<p:confirm header="Confirmation" message="Are you sure you delete this?" 
    icon="ui-icon-alert" /> 
</p:commandButton> 
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade"> 
<p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" 
    icon="ui-icon-check" /> 
<p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" 
icon="ui-icon-close" /> 
</p:confirmDialog> 

這是我的Java方法是調用當按鈕是點擊

public String doCheckin(long checki) { 

    CheckoutDb.checkinBook(checki); 
    getCheckoutList(); 

    return "checkoutList?facesRedirect=true"; 
} 

public List getCheckoutList() { 
    return checkoutList = CheckoutDb.selectCheckedOutBooks(); 
} 

任何幫助,請

+1

你犯了一個錯誤與 「facesRedirect」 的 –

+0

第一所有你使用面向重定向的錯誤語法,它應該是'?faces-redirect = true'。 –

+1

雖然你通常會做一個AJAX更新,而不是重新加載整個頁面。 –

回答

0

你應該有一個動作連接到按鈕標記爲「是」。

喜歡的東西:

<p:commandButton action="#{checkoutListBean.reloadPage()}" value="Yes" type="button" styleClass="ui-confirmdialog-yes" 
    icon="ui-icon-check" /> 

然後在豆:

public String reloadPage() { 
    return "checkoutList?faces-redirect=true"; 
} 
0

您必須更改重定向

public String doCheckin(long checki) { 

    CheckoutDb.checkinBook(checki); 
    getCheckoutList(); 

    return "checkoutList?faces-redirect=true"; 
} 

public List getCheckoutList() { 
    return checkoutList = CheckoutDb.selectCheckedOutBooks(); 
} 
相關問題