liferay 日历使用

日历,只显示日期 :
liferay中源码 可以参考 ->liferay中portal-web/docroot/html/portlet/enterprise-admin/user/details.jsp

其中jsp页面中写:
Contact selContact = (Contact)request.getAttribute("user.selContact");
Calendar birthday = CalendarFactoryUtil.getCalendar();

birthday.set(Calendar.MONTH, Calendar.JANUARY);
birthday.set(Calendar.DATE, 1);
birthday.set(Calendar.YEAR, 1970);

if (selContact != null) {
birthday.setTime(selContact.getBirthday());
}


<div>
<c:choose>
<c:when test="<%= PropsValues.FIELD_ENABLE_COM_LIFERAY_PORTAL_MODEL_CONTACT_BIRTHDAY %>">
<liferay-ui:input-field model="<%= Contact.class %>" bean="<%= selContact %>" field="birthday" defaultValue="<%= birthday %>" />
</c:when>
<c:otherwise>
<input name="<portlet:namespace />birthdayMonth" type="hidden" value="<%= Calendar.JANUARY %>" />
<input name="<portlet:namespace />birthdayDay" type="hidden" value="1" />
<input name="<portlet:namespace />birthdayYear" type="hidden" value="1970" />
</c:otherwise>
</c:choose>
</div>


带时间的liferay 日历:
可参考:portal-web/docroot/html/portlet/calendar/edit_event.jsp
其中在jsp添加:
CalEvent event = (CalEvent)request.getAttribute(WebKeys.CALENDAR_EVENT);

Calendar selCal = CalendarFactoryUtil.getCalendar(timeZone, locale);
Calendar startDate = CalendarUtil.roundByMinutes((Calendar)selCal.clone(), 15);

if (event != null) {
if (!event.isTimeZoneSensitive()) {
startDate = CalendarFactoryUtil.getCalendar();
}

startDate.setTime(event.getStartDate());
}

Calendar endDate = (Calendar)selCal.clone();

endDate.set(Calendar.HOUR_OF_DAY, 23);
endDate.set(Calendar.MINUTE, 59);

开始时间:<liferay-ui:input-field model="<%= CalEvent.class %>" bean="<%= event %>" field="startDate" defaultValue="<%= startDate %>" />结束时间:<liferay-ui:input-field model="<%= CalEvent.class %>" bean="<%= event %>" field="endDate" defaultValue="<%= endDate %>" />


如果出现错误情况,有可能是未加入需要的包,上面不带时间的日历,在jsp中未引入包可以正常使用,但后面带时间的日历需要引入calevent包进来才可以正确使用
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值