Need to set value of inputCalendar element to current day
I need to automatically set the value of my input开发者_Python百科Calendar 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.
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();
}
// ...
}
精彩评论