Model View Controller Framework

The Model-View-Controller (MVC) paradigm is a design pattern used for creating applications. It partitions the separate concerns of application data, user interface and application logic into three discrete components. It has proven highly successful in simplifying application design and maintenance.

The Ejscript Web Framework is a Model-View-Controller environment that provides a structure and assistance for your MVC application. It provides the basis and connections between your models, views and controllers and routes messages between the various components.

Ejscript makes MVC programming easy by providing base classes that implement most of the plumbing for an MVC application.

Models

The model is responsible for managing access to application data and state. It is also responsible for ensuring the data remains valid and consistent.

Ejscript provides an Object Relational Mapper (ORM) via the the Model class. This wraps database data in JavaScript objects and allows you to use object-oriented programming (OOP) when dealing with database data stored in rows and columns. The model class makes SQL programming more natural in OOP programs.

Views

The view is responsible for rendering the user interface and presenting the application to the user. Views should not manage incoming requests — that is the job of Controllers.

Ejscript provides the View class and a powerful embedded scripting environment. HTML pages with embedded JavaScript code are compiled and run to render the user interface. The view mechanism also provides a templating engine so you can deal separately with layout pages and content pages.

Controllers

Controllers manage the application and respond to client requests. They orchestrate the application's response, access and update model data, and display views back to the client. Incoming requests invoke Actions in the controller which modify the application state and ultimately render a view.

Ejscript routes requests by parsing and decoding request URLs and matching them with the appropriate Controller and Action function. Ejscript provides the Controller class that provides methods for interacting with models and rendering views.

© Embedthis Software, 2003-2015. All rights reserved.