The interaction among the data model and how it show and user interaction is applied to the data model is done by the controller. Controllers are a set of CGIs and some JavaScript helper functions which manage how the user interact with eBox data models.
We have defined two kinds of CGIs, View and Controller. The former is a usual CGI
which inherits from EBox::CGI::ClientBase
and returns a complete
HTML page to override the current one and contains the menu on the left and the top.
Nevertheless, the latter is a new CGI class which inherits from
EBox::CGI::ClientRawBase
and gets back only the generated
HTML page by the requested action as well as different HTTP code to be interpreted
at the client side to set exceptions such as 500 or data in use 501. This is very useful
to develop a simple and elegant way to manage exceptions within the application flow.
The View CGI is called when the whole page loading is required, for instance clicking
on a menu item and the Controller CGIs are called whenever an action (add, del, edit,
move...) is done to a data model. This adaption is done allowing AJAX requests. This
MVC scheme now relies on Prototype JavaScript framework
to handle DOM and AJAX requests making eBox web application cross browser as far as
prototypeJS ensures it.
Every JavaScript function is implemented in a separated file grouping by functionality. There is also some JavaScript classes to implement tabbing using JavaScript only. This increases its maintainability centralising the client side logic and it decouples from what is used to display the information, i.e. the mason templates.