p:对话框没有从p:schedule中提取日期

时间:2016-01-01 12:31:45

标签: jsf primefaces dialog

我的p:日程安排不正常。当我点击日期时,它会显示一个包含开始日期和结束日期的弹出窗口。但它没有在弹出窗口中提取日期。我按照展示的示例进行操作,但弹出窗口时日期字段为空。

appointment.xhtml

 <h:form prependId="false">
  <p:schedule id="schedule"
            value="#{Appointment.eventModel}"
            widgetVar="myschedule"
            timeZone="GMT+2">

    <p:ajax event="dateSelect"
            listener="#{Appointment.onDateSelect}"
            oncomplete="PF('eventDialog').show();" />

    <p:ajax event="eventSelect"
            listener="#{Appointment.onEventSelect}"
            update="eventDetails"
            oncomplete="PF('eventDialog').show();" />
</p:schedule>

<p:dialog widgetVar="eventDialog"
          header="Appointment Details"
          showEffect="clip"
          hideEffect="clip">

    <h:panelGrid id="eventDetails" columns="2">
        <p:outputLabel for="title" value="Titles:" />
        <p:inputText id="title"
                     value="#{Appointment.event.title}"
                     required="true" />

        <p:outputLabel for="from" value="From:" />
        <p:calendar id="from"
                    value="#{Appointment.event.startDate}"
                    timeZone="GMT+2" pattern="dd/MM/yyyy HH:mm" />

        <p:outputLabel for="to" value="To:" />
        <p:calendar id="to"
                    value="#{Appointment.event.endDate}"
                    timeZone="GMT+2" pattern="dd/MM/yyyy HH:mm" />


        <p:commandButton type="reset" value="Reset" />
        <p:commandButton id="addButton" value="Save"
                         actionListener="#{Appointment.addEvent}"
                         oncomplete="PF('myschedule').update();
                                     PF('eventDialog').hide();"/>
    </h:panelGrid>
</p:dialog>
</h:form>

Appointment.java

public class Appointment implements AppointmentInterface {

    public ScheduleModel getEventModel() {
        eventModel = new DefaultScheduleModel();
        return eventModel;
    }

    public void onDateSelect(SelectEvent selectEvent) {
        event = new DefaultScheduleEvent("", (Date) selectEvent.getObject(), (Date) selectEvent.getObject());
    }

    public void onEventSelect(SelectEvent selectEvent) {
        event = (ScheduleEvent) selectEvent.getObject();
    }

    public void addEvent(ActionEvent actionEvent) {
        if (event.getId() == null) {
            eventModel.addEvent(event);
        } else {
            eventModel.updateEvent(event);
        }

        event = new DefaultScheduleEvent();
    }
}

0 个答案:

没有答案