How to add zCalendar events on startup through java code.

asked 2013-11-19 19:11:00 +0800

willkara gravatar image willkara

updated 2013-11-20 13:43:54 +0800

So I have successfully implemented a basic calendar object in a Java WebApp. What my plan is, is to take some other data from an outside source and populate the calendar with those events.

So what I need to do is populate the calendar with event data on server startup. I want to be able to do this through all Java code. I used the ZKCalendarEssentials walkthrough to set it up.

Once I am able to add events on server startup through Java, I'll be in the clear. I am using tomcat 7 as my server.

Why can't I add comments to an answer?

I had to put this as an edit because there is not 'comments' field under an answer. So far, I am just trying to get a simple Proof of Concept working so no MVC or MVVM yet. What my goal is, I want to be able to make a class that extends the ContextListener for Java/Tomcat so that it runs on startup and loads up the event data. After that, the calendar would add this data on its own startup.

I can't add links yet so it's books.zkoss.org/wiki/ + ZKDeveloper'sReference/MVC/Controller/Composer

^This is what I found for some ideas^

Would you be able to give me an example of setting up the MVC or MVVM for the calendar? It is simple enough for me to configure the code to run on Tomcat Startup, but I am stuck on adding events to the calendar when the page loads through Java. Thanks!

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2013-11-20 08:23:00 +0800

chillworld gravatar image chillworld flag of Belgium
5357 4 9

updated 2013-11-20 14:45:52 +0800

First of all, do you use MVC or MVVM?

In(MVC) your controller you extend SelectorComposer<component>, so override the following and put your events there in your calendar.

public final void doAfterCompose(Component comp) throws Exception {

This is from an previous project of me in mvc :

  * After composing the page, the calendar and customerlist are initialised.
  * In the calendar we put a model calendarModel with all the values of the
  * deliveries that are already plannified. The two list are initialised with
  * deliveries that has to be planified and the deliveries that are marked as
  * selfservice.
  * @param comp initial component
  * @throws Exception can throw an exception
public final void doAfterCompose(Component comp) throws Exception {

  * initiate the model of the calendar.
private void initCalendarModel() {         
    calendarModel = new SimpleCalendarModel();         
    Calendar cal = Calendar.getInstance();         
    cal.setTime(new Date());         
    cal.add(Calendar.MONTH, 1);         
    cal.add(Calendar.MONTH, -2);         

  * creates the content of the calendar event.
  * @param beginDate date of the event
private void addEventsMonth(Date beginDate) {
     for (Delivery delivery : deliveryService.getDeliveryPlanningForMonth(beginDate)) {
         CalendarEvent ce = PlanningUtil.createEvent(delivery);

I hope this helps you.

Greetz Chill.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2013-11-19 19:11:00 +0800

Seen: 13 times

Last updated: Nov 20 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More