2010-05-09 41 views
0

在我的應用程序中,我預先填充了服務器中的一些數據。當我分配<rich:Calendar>的數據時,我無法在用戶界面中看到日期。我試圖將字符串從數據庫轉換爲日期格式。請幫助。如何在JSF中預先填充<rich:calendar>?

我的JSF代碼

<a4j:outputPanel> 
<rich:calendar id="myCalendar" popup="true" mode="client" 
    preloadDateRangeBegin="#{item.date}" preloadDateRangeEnd="#{item.date}" 
    value="#{item.date}" showApplyButton="true" 
    cellWidth="24px"cellHeight="22px" style="width:200px"> 
</rich:calendar> 
</a4j:outputPanel> 

日期轉換,我使用

DateFormat dateForm = new SimpleDateFormat("MM/dd/YYYY"); 
    Date date = dateForm.parse(lastRunDate); 

回答

2
  • 使用<f:converDateTime>,並具有如下性質:item.date爲類型Date

    <rich:calendar id="myCalendar" popup="true" mode="client" 
         value="#{item.date}" showApplyButton="true" 
         cellWidth="24px"cellHeight="22px" style="width:200px"> 
        <f:converDateTime type="date" pattern="MM/dd/yyyy" /> 
    </rich:calendar> 
    
  • 擺脫preloadDateRangeX屬性

相關問題