我有这个PrimeFaces Schedule组件:
<h:form>
<p:growl id="messages" showDetail="true" />
<h:panelGrid columnClasses="value">
<h3>Lazy Schedule</h3>
<p:schedule value="#{visorBean.eventModel}" timeFormat="H:mm"
draggable="true" firstHour="8" minTime="8:00" maxTime="22:00"
resizable="true" axisFormat="H:mm" view="agendaWeek">
<p:ajax event="eventMove" listener="#{viwerBean.onEventMove}"
update="messages" />
<p:ajax event="eventResize" listener="#{viwerBean.onEventResize}"
update="messages" />
</p:schedule>
</h:panelGrid>
</h:form>
支持bean:
public void onEventMove(ScheduleEntryResizeEvent event) {
String msg;
if(isEventValid(event)) {
msg = "Ok!";
} else {
msg = "Ops!";
revertFunction(); // Undo change
}
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Event resized", msg);
addMessage(message);
}
如何在不允许事件时撤消更改(例如,事件必须在上午8点之后开始)?