TheNewGuy
TheNewGuy

Reputation: 53

Need to set value of inputCalendar element to current day

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

Answers (1)

BalusC
BalusC

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

Related Questions