我想使<p:calendar>
只讀,以便用戶只能從日曆中選擇一個日期,因爲this問題(但這不是解決方法)。使p:日曆只讀
對於這個是這樣,我做readonly="#{facesContext.renderResponse}"
由this答案就像提到,
<p:calendar id="calendarId"
value="#{bean.property}"
converter="#{jodaTimeConverter}"
pattern="dd-MMM-yyyy hh:mm:ss a"
showOn="button"
readonly="#{facesContext.renderResponse}"
effect="slideDown"
required="true"
showButtonPanel="true"
navigator="true"/>
這工作,但在頁面加載(輸入在地址欄中的URL,然後按回車鍵),facesContext.renderResponse
返回false
並且日曆不再只讀。當我通過按<p:commandButton>
提交表單時,它的計算結果爲true
。
那麼,如何使日曆只讀,當頁面加載?
P.S:我正在使用PrimeFaces 3.5和Mojarra 2.1.9。
這是非常好的解決方案:) –