Jsf iCal4j和使用primefaces p.schedule

Jsf iCal4j和使用primefaces p.schedule,jsf,primefaces,schedule,ical4j,Jsf,Primefaces,Schedule,Ical4j,我目前正在尝试使用ical4j和p:schedule 我正在生成我的ical4j事件,如下所示: public void createEvent(BookingDate bookingDate, Mandatory mandatory, Employee employee) throws FileNotFoundException, IOException, ParserException, ConstraintViolationException { // Creat

我目前正在尝试使用ical4j和p:schedule

我正在生成我的ical4j事件,如下所示:

public void createEvent(BookingDate bookingDate, Mandatory mandatory, Employee employee)
        throws FileNotFoundException, IOException, ParserException, ConstraintViolationException {

    // Create a TimeZone
    System.setProperty("net.fortuna.ical4j.timezone.cache.impl", MapTimeZoneCache.class.getName());

    TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
    TimeZone timezone = registry.getTimeZone("Europe/Berlin");
    VTimeZone tz = timezone.getVTimeZone();

    String pathMandatoryFile = null;
    String pathEmployeeFile = null;

    // Reading the file and creating the calendar

    Calendar icsCalendar = null;


    if (bookingDate.isCreateCalendarMandatoryEntry()) {
        // timezone = registry.getTimeZone(mandatory.getTimeZone());

        pathMandatoryFile = mandatory.getDirectoryRootFolder();
        pathMandatoryFile = pathMandatoryFile + File.separator + ConstantsStorage.CALENDAR_FOLDER + File.separator
                + "calendar.ics";

        try {
            FileInputStream fin = new FileInputStream(pathMandatoryFile);
            CalendarBuilder builder = new CalendarBuilder();
            icsCalendar = builder.build(fin);
        } catch (Exception e) {
            e.printStackTrace();
        }

        // Wenn noch kein Kalender vorhanden, dann erstellen
        if (icsCalendar == null) {
            icsCalendar = createNewCalender(pathMandatoryFile);
        }
    }

    // Creating an event
    java.util.Calendar startCal = java.util.Calendar.getInstance(timezone);
    startCal.set(java.util.Calendar.YEAR, bookingDate.getStartDate().getYear());
    startCal.set(java.util.Calendar.MONTH, bookingDate.getStartDate().getMonth());
    startCal.set(java.util.Calendar.DAY_OF_MONTH, bookingDate.getStartDate().getDate());
    startCal.set(java.util.Calendar.HOUR_OF_DAY, bookingDate.getStartDate().getHours());
    startCal.set(java.util.Calendar.MINUTE, bookingDate.getStartDate().getMinutes());
    startCal.set(java.util.Calendar.SECOND, bookingDate.getStartDate().getSeconds());

    java.util.Calendar endCal = java.util.Calendar.getInstance(timezone);
    endCal.set(java.util.Calendar.YEAR, bookingDate.getEndDate().getYear());
    endCal.set(java.util.Calendar.MONTH, bookingDate.getEndDate().getMonth());
    endCal.set(java.util.Calendar.DAY_OF_MONTH, bookingDate.getEndDate().getDate());
    endCal.set(java.util.Calendar.HOUR_OF_DAY, bookingDate.getEndDate().getHours());
    endCal.set(java.util.Calendar.MINUTE, bookingDate.getEndDate().getMinutes());
    endCal.set(java.util.Calendar.SECOND, bookingDate.getEndDate().getSeconds());

    net.fortuna.ical4j.model.DateTime dtStart = new DateTime(startCal.getTime());
    dtStart.setTimeZone(timezone);


    net.fortuna.ical4j.model.DateTime dtEnd = new DateTime(endCal.getTime());
    dtEnd.setTimeZone(timezone);


    String eventName = bookingDate.getName();
    VEvent meeting = new VEvent(dtStart, dtEnd, eventName);

    // add timezone info..
    meeting.getProperties().add(tz.getTimeZoneId());
    String uidValue = bookingDate.getIdHash();
    meeting.getProperties().add(new Uid(uidValue));

    // Add the event and print
    icsCalendar.getComponents().add(meeting);

    CalendarOutputter outputter = new CalendarOutputter();
    FileOutputStream fout = new FileOutputStream(pathMandatoryFile);
    outputter.output(icsCalendar, fout);

}
.cal文件中的我的输出:

BEGIN:VCALENDAR
PRODID:-//Ben Fortuna//iCal4j 1.0//EN 版本:2.0 CALSCALE:格里高利 开始:VEVENT DTSTAMP:20180830T200603Z DTSTART;TZID=欧洲/柏林:01180808T000000 数据终端;TZID=欧洲/柏林:01180808T000000 摘要:MegaTest TZID:欧洲/柏林 UID:1535659563533-b091a66c-5a0e-4730-bba2-cf94e6763514 完:维文特 开始:VEVENT DTSTAMP:20180830T202034Z DTSTART;TZID=欧洲/柏林:011806亿 数据终端;TZID=欧洲/柏林:011806亿 摘要:dasas TZID:欧洲/柏林 UID:1535660434464-3db07bd9-eff0-4c28-9178-5cca1be89e23 完:维文特 开始:VEVENT DTSTAMP:20180830T202245Z DTSTART;TZID=欧洲/柏林:01180830T230000 数据终端;TZID=欧洲/柏林:01180830T231000 小结:测试 TZID:欧洲/柏林 UID:1535660561611-a9341234-5186-469e-9ad6-5b9c754221e7 完:维文特 完:VCALENDAR

现在我尝试使用p:schedule在日程表中显示它,但它不起作用(我猜是由于p:schedule的日期格式错误,因为列表中包含了我的事件…)

下面是我的Primefaces代码p:计划:

public void loadAllEvents() {
    lazyEventModel = new LazyScheduleModel() {

        @Override
        public void loadEvents(Date start, Date end) {
            try {

                CalendarExtern calendarExtern = new CalendarExtern();
                calendarExtern.setSelectedForView(true);
                readFromFile(calendarExtern);


                SimpleDateFormat SDF = new SimpleDateFormat("yyyyMMdd'T'HHmmss");

                net.fortuna.ical4j.model.Calendar calendar = null;

                if (calendarExtern.getUrl() == null) {
                    calendar = bookingCalendarService.readCalenderFromFile(calendarExtern);
                }

                else {
                    calendar = bookingCalendarService.readCalenderFromUrl(calendarExtern);
                }

                for (Iterator i = calendar.getComponents().iterator(); i.hasNext();) {
                    Component component = (Component) i.next();
                    // new event

                    // Date start = SDF.parse(component.getProperty("DTSTART").getValue());
                    // Date end = SDF.parse(component.getProperty("DTEND").getValue());

                    String startTime = component.getProperty(Property.DTSTART).getValue();
                    Date startDate = SDF.parse(startTime);

                    String endTime = component.getProperty(Property.DTEND).getValue();
                    Date endDate = SDF.parse(endTime);


                    String summary = component.getProperty("SUMMARY").getValue();

                    addEvent(new DefaultScheduleEvent(summary, startDate, endDate));


            } catch (Exception e) {

            }
        }
    };
}
我应该改变什么来解决这个问题?

你应该(akways)从缩小问题的范围开始。PF时间表与ical无关。它是介于两者之间的代码。调试ical中用于eventmodel的值,然后将其作为静态值进行尝试。也许你会看到一些不寻常的事情……而“但它不起作用”有点含糊不清,(我猜是因为p:schedule的日期格式错误,…)正是我的调试建议所涉及的内容。。。提示:开始和结束看起来很奇怪。。。0118?