<h:form>
<h:selectOneMenu value="#{bean.timezone}>
<f:selectItems value="#{bean.availableTimezones} ... >
<f:ajax render="currenttime" />
</h:selectOneMenu>
</h:form>
<h:form id="currenttime">
<h:outputText value="#{bean.currentTime}" >
<f:convertDateTime dateStyle="short" type="both" timeZone="#{bean.timezone}" />
</h:outputText>
</h:form>
<!-- bean.currentTime is of type 'Date' -->
在該示例中,改變了時區應使文本中currenttime
在適當的時區中顯示。但事實並非如此。
我覺得發生這種情況是因爲轉換器是在「應用請求」階段計算的,所選時區的值是在「更新模型」階段更新的。
我對不對? 我不應該使用轉換器嗎?
謝謝!
是您的H? –
是的,與輸出文本不同的形式不同.Tnx的評論,我會更新問題。 – Ben