日历,只显示日期 :
liferay中源码 可以参考 ->liferay中portal-web/docroot/html/portlet/enterprise-admin/user/details.jsp
其中jsp页面中写:
带时间的liferay 日历:
可参考:portal-web/docroot/html/portlet/calendar/edit_event.jsp
其中在jsp添加:
如果出现错误情况,有可能是未加入需要的包,上面不带时间的日历,在jsp中未引入包可以正常使用,但后面带时间的日历需要引入calevent包进来才可以正确使用
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包进来才可以正确使用