Reputation: 53
I need to automatically set the value of my inputCalendar element to the current date yet still allow the user to click on the popup calendar to change the value if they wish. The code I am using is found below.
<t:inputCalendar id="dashDelivStartDateCal" monthYearRowClass="yearMonthHeader" weekRowClass="weekHeader" popupButtonStyleClass="standard_bold" currentDayCellClass="currentDayCell" value="#{orderStatusBacking.dashDelivStartDate}" renderAsPopup="true" popupDateFormat="MM/dd/yyyy" helpText="MM/DD/YYYY">
<h:message for="dashDelivStartDateCal" showDetail="true"></h:message>
</t:inputCalendar>
Thanks in advance for the help.
Upvotes: 2
Views: 940
Reputation: 1109695
Just initialize the value behind value="#{orderStatusBacking.dashDelivStartDate}"
with current date instead of (default) null
. You can do this in the constructor of the bean.
public class OrderStatusBacking {
private Date dashDelivStartDate;
public OrderStatusBacking() {
dashDelivStartDate = new Date();
}
// ...
}
Upvotes: 2