2013-07-19 58 views
0

我有一個<form>用戶可以在其中輸入數據。當他輸入正確的數據並且用戶按下按鈕時,我想用謝謝信息替換這個<form>。實際上應該出現一個帶有文本的<div>容器。用文本替換表格

在Primefaces 3.5或JSF中實現這一點的好方法是什麼?

回答

1
  • 假設你有一個父div,其中有兩個div。一個用於表單,一個用於感謝您的消息。
  • 首先,將表單面板設置爲可見,並感謝您的郵件爲不可見。
  • 如果表單成功提交,則將一些支持bean值更改爲true,這將負責顯示謝謝消息。
  • 現在,在提交表格後,將其面板的可見性更改爲false,並感謝您的留言可見性至true

    <p:outputPanel id="parentPanel"> 
        <p:outputPanel id="formPanel" rendered="#{bean.render eq '1'}"> 
          //Your form here 
        </p:outputPanel> 
        <p:outputPanel id="textPanel" rendered="#{bean.render eq '2'}"> 
          //Your thank you message here 
        </p:outputPanel> 
        </p:outputPanel> 
    

這裏,render在表單提交後,將從1改變2 bean的屬性。

+0

Thx!然而,我不能在'div-container'中應用'rendered' ... – maximus

+0

如果你使用primefaces,那你爲什麼不使用'outputPanel'? –

+0

感謝您的回答!但是,當我使用''時,只有第一個'div'消失,頁面上不顯示任何內容......(呈現屬性中的值爲TRUE;!) – maximus