我使用convertDateTime標籤DataTable中每個組件的Ajax請求。將託管bean屬性連接到timezone屬性。在這種情況下,每個Ajax請求都會重新創建Managed Bean。使用convertDateTime標籤並重新創建Managed Bean的
管理bean範圍視圖作用域。
<h:column>
<f:facet name="header">
<h:outputLabel value="Date"/>
</f:facet>
<h:outputText value="#{item.date}">
<f:convertDateTime timeZone="#{myBean.timezone}" locale="tr" pattern="dd.MM.yyyy"/>
</h:outputText>
</h:column>
@ManagedBean(name="myBean")
@ViewScoped
public class MyBean {
@PostConstruct
public void initBeanMethod(){
System.out.println("PostConstruct method is called...");
}
private TimeZone timezone = TimeZone.getDefault();
public TimeZone getTimezone() {
return timezone;
}
public void setTimezone(TimeZone timezone) {
this.timezone = timezone;
}
顯示每個AJAX請求後,下面的輸出:「PostConstruct方法被稱作......」
你有關於每個請求豆再創造的想法?
注:我爲我的英語不好道歉:)
Hi BalusC。感謝您的啓發迴應。我已經使用上下文參數,但這不足以獲得準確的結果。您的共享鏈接將仔細閱讀。再次感謝你... – hakdogan