-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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!
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.
@Override
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
*/
@Override
public final void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
initCalendarModel();
calendars.setModel(calendarModel);
initCustomerList();
calendars.setContext(deletePopup);
initPopupMenu();
}
/**
* initiate the model of the calendar.
*/
private void initCalendarModel() {
calendarModel = new SimpleCalendarModel();
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
addEventsMonth(cal.getTime());
cal.add(Calendar.MONTH, 1);
addEventsMonth(cal.getTime());
cal.add(Calendar.MONTH, -2);
addEventsMonth(cal.getTime());
}
/**
* 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);
calendarModel.add(ce);
}
}
I hope this helps you.
Greetz Chill.
Asked: 2013-11-19 19:11:00 +0800
Seen: 13 times
Last updated: Nov 20 '13
[Bug] ZK Calendar getting exception
Calendar month view - title instead of content
zk calendar onEventCreate doesn't work notifyChange
Calendars - Custom CSS and HTML
Calendar translation (german) for setWeekOfYear(true)
Can I dowload the ZK Calenda demo? [closed]