Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Calendar AddOn action Listener overwriting
Hello!
I have a question according to the Calendar addOn. In the week view there are two buttons where I can go back or forward for one week. How can I overwrite this two listeners. The reason for this is that I only load the events of the displayed week. Therefore if the user jumbs back for one week I need to load the events for that week from the database. I need this because there are a lot of events and I cannot load them completley.
Thanks for any help!
Florian
You can create your own handlers for forward and back events. Here's an example:
/**
* Handles moving backward in the calendar
*/
calendar.setHandler(new BasicBackwardHandler() {
@Override
public void backward(BackwardEvent event) {
// Load the data here
super.backward(event);
}
});
/**
* Handles moving forward in the calendar
*/
calendar.setHandler(new BasicForwardHandler() {
@Override
public void forward(ForwardEvent event) {
// Load the data here
super.forward(event);
}
});
Thank you very much this was big help. But I have one question remaining: If I press the backwar or forward button is there chance you get the new start and end date, I mean I define when I create the calendar the start and end date. But when I press one of these two buttons this dates are not changed. Can I get the current dates or do I have to solve this in another way.
Thanks,
Florian
If you need the new dates instead of the old ones then instead of overriding backward()/forward() methods you can override the setDates(..) method. The start and end dates are the new dates.
Here is an example:
/**
* Handles moving backward in the calendar
*/
calendar.setHandler(new BasicBackwardHandler() {
@Override
protected void setDates(BackwardEvent event, Date start, Date end) {
// Load the data here
super.setDates(event, start, end);
}
});
Hello!
I just want to say thank you for your help, I know it has been a long time ago but the last month I was to busy with management for writing any line of code.
That helped me much!
Florian