Hariharbalaji
Hariharbalaji

Reputation: 2578

How to Prepopulate <rich:calendar> in JSF?

In My application I am pre-populating some data from the Server. When I assign the data for the <rich:Calendar> I am not able to see the date in the UI. I am trying to convert the string from the database to Date format. Kindly help.

My JSF Code

 <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>

Date Conversion I am Using

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

Upvotes: 0

Views: 4630

Answers (1)

Bozho
Bozho

Reputation: 597124

  • use <f:converDateTime>, and have the property item.date to be of type 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>
    
  • get rid of preloadDateRangeX attributes

Upvotes: 2

Related Questions