2012-11-03 35 views
0

我有這樣的JSF按鈕:禁用的按鈕,當我刷新網頁與F5

<h:commandButton style="position:absolute; bottom:12px; right:12%;" styleClass="lbimage" onclick="this.disabled=true" value=" Edit Account " rendered="#{not AccountProfileTabGeneralController.editable}" action="#{bean.editAccount(true)}" > 
    <f:ajax render="@form" execute="@form"></f:ajax> 
</h:commandButton>&nbsp; 

我添加代碼執行時這個JS爲了防止雙擊:

onclick="this.disabled=true" 

但是,當我用F5刷新網頁,當頁面加載時,按鈕被禁用。我如何防止這種情況發生?

+0

檢查[此鏈接](http://ocpsoft.org/java/jsf-java/jsf2-how-to-create-a-global-ajax-status-indicator/ )以便使用普通的JSF 2和JavaScript來解決您的問題。否則,最好使用處理像[PrimeFaces](http://www.primefaces.org/showcase-labs/ui/ajaxStatusScript.jsf)或[RichFaces](http:// showcase.richfaces.org/richfaces/component-sample.jsf?demo=status&skin=blueSky)(在最後一種情況下,您必須將ajax狀態更改爲使用'')。 –

回答

0

onclick="this.disabled=true",還可以使用oncomplete="this.disabled=false"

+0

在標籤'h:commandButton'中,沒有屬性'oncomplete'。 – user1285928

+0

是的,但你可以通過使用jquery使用oncomplete函數。或者使用primefaces或richfaces命令按鈕,因爲這些庫支持不完整的 – olyanren

+0

使用具有'oncomplete'事件的''。 – prageeth

相關問題