如何解决需要将inputCalendar元素的值设置为当天
| 我需要自动将我的inputCalendar元素的值设置为当前日期,但仍允许用户单击弹出日历以更改值。我正在使用的代码如下。<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>
先谢谢您的帮助。
解决方法
只需使用当前日期而不是(默认)
null
来初始化value=\"#{orderStatusBacking.dashDelivStartDate}\"
后面的值。您可以在Bean的构造函数中执行此操作。
public class OrderStatusBacking {
private Date dashDelivStartDate;
public OrderStatusBacking() {
dashDelivStartDate = new Date();
}
// ...
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。