I am trying to create a Calendar application in JavaFX using MVC. What I have in mind is something as what is shown in the image below:
Basically:
- I have a
CalendarView
(red background) showing the title of the calendar (“Calendar for today”) and the labels of the hours of the day. ThisCalendarView
includes a container (blue background), that works as a holder for the individual appointments. - I have an
AppointmentView
(green background) which is generated for each and every appointment in the calendar.
Based on this scenario, my idea would be doing something as follows:
- Create an
AppointmentModel
class as model for the appointment - Create a
CalendarModel
class as model for the calendar. This class includes alist of AppointmentModel
- Create a controller for the appointment, called
AppointmentController
. This controller will include an instance of anAppointmentModel
class and anAppointmentView
class - Create a controller for the calendar, called
CallendarController
. This controller will include an instance of aCalendarModel
class andCalendarView
class
I have written the following pseuocode to describe this scenario:
public class AppointmentModel {
...
}
public class CalendarModel {
List<AppointmentModel> appointments;
...
}
public class AppointmentController {
AppointmentModel model;
AppointmentView view;
...
}
public class CalendarController {
CalendarModel model;
CalendarView view;
...
}
The problem I find now is how to link the calendar and the appointments. In the code above I have included List<AppointmentModel> appointments;
inside CalendarModel
, but by doing this, I do not know what to do with AppointmentController
. Only thing I could think of is including a List<ApointmentControllers> ...
in CalendarController
and removing the List<AppointmentModel> ...
from CalendarModel
, but this does not make sense for me, as the CalendarModel
, by definition, implies a list of appointments.
What am I missing in my reasoning?
Go to Source
Author: Fernando Cereijo