开发者

Need to set value of inputCalendar element to current day

开发者 https://www.devze.com 2023-03-08 09:38 出处:网络
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 cod

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();
    }

    // ...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号