Model-View-Control

Introduction

The MVC approach is currently "best practice" in design of software applications, including web applications. Achieving this ideal is not always straightforward. In Cocoon, there has been rapid development between 2.0 and 2.1.5; with new technology and approaches being added in, and many users linking in technologies from outside of Cocoon.

This page attempts to create a synthesis of what is/has been done to achieve MVC.

The Big Picture

http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105955717614416&q=p3

The Model

The Model represents all the logic in the application that is not related to the viewing or sequencing of pages. Logic is essential for making appropriate changes to the data layer of your applications (usually in a database of some type) and encapsulates the business rules supplied to the developer by the users/analyst.

In Cocoon, model logic usually resides in Java objects.

The View

The View is what the end user sees; either raw data, or data that has been manipulated in some and laid out ("presented") in an aesthically pleasing, or functionally useful, way.

The primary mechanism for creating a view in Cocoon is the XSLT transformer which operates on the XML in the pipeline, prior to it being serialized for display/download.

Note that an entire Cocoon pipeline, from data retrival, through to final deliver, can also be considered a "view", provided that the source data is not altered during this process.

The Control

Control, in Cocoon 2.1.3 onwards, is handled by GettingStartedWithFlow. Flow is essentially a series of Javascript functions, called from the sitemap, which can:

  • instantiate objects from the model
  • get and set values from these objects
  • determine the order in which pages are sent to the user
  • obtain data from forms submitted by the user
  • update objects by passing them new data

Conclusions

Related Resources

  • No labels