0

I am using a schedule in my application like this:

<p:schedule id="performanceSchedule" value="#{performanceScheduleView.eventModel}" />

Another component modifies the schedule's datamodel by calling this method of the view:

private void updatePerformances() {
    eventModel.clear();
    for (final PerformanceModel perf : dataStorage.getPerformancesForVenue(activeVenueId)) {
        final ArtistModel artist = dataStorage.getArtistById(perf.getArtistId());
        final Date perfStart = perf.getDate();
        final Date perfEnd = new Date(perfStart.getTime() + 1000 * 60 * 60);
        eventModel.addEvent(new DefaultScheduleEvent(artist.getName(), perfStart, perfEnd));
    }
}

But this means the user has to go to another date and back, else the changes are not visible to the client.

My first idea was to do polling like this:

<h:form>
    <p:poll interval="1" update="performanceSchedule" />
</h:form>

But this causes the schedule to jump to the current date and makes it unusable.

Any suggestions how to workaround that problem?

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Ethon
  • 93
  • 2
  • 12

1 Answers1

0

Did you try to add initialDate property?

<p:schedule id="performanceSchedule" value="#{performanceScheduleView.eventModel}" initialDate="#{performanceScheduleView.initialDate}" />

and set each time the right value on the backing bean.

giaffa86
  • 708
  • 1
  • 9
  • 22
  • That should work but then there's still the problem that my schedule has scroll bars and when scrolling down it jumps up on each update. – Ethon Jan 13 '16 at 14:20
  • Yes that is an annoying problem. Did you check this out? http://stackoverflow.com/questions/22804833/scroll-to-top-on-messages-rendered-in-primefaces – giaffa86 Jan 13 '16 at 14:26
  • And better to use push so it is only updated when it needs to be updated – Kukeltje Jan 13 '16 at 14:53
  • You can use scrollTo every time it needs to be updated, without using poll. – giaffa86 Jan 13 '16 at 15:10