Intersection of Business and UI logic

You've just learned about the powerful tools to create Business Logic and User Interface. Both are quite awesome tools on their own, but to make things even simpler, Views can work with Models directly. This "Glue" functionality is implemented through Controllers.

Controller is an object in Agile Toolkit which is designed to manipulate or enhance the functionality of another object.

In many cases you wouldn't know that you are using a Controller. In Agile Toolkit many controllers are generic. The effects are vast starting from enabling Caching in Model down to implementation of whole Libraries of custom functions related to particular area of your application logic.

In this introduction I wanted to demonstrate how Controller_MVCForm makes it possible to populate your form fields, labels, conditions, types, validations from the model and also add ability for a form to save data back through the model.




$form $page->add('Form');
Full Documentation on Controllers

Create, Read, Update, Delete = CRUD

Crud Generators are evil. They provide no flexibility, duplicate awful amount of code and have no consistency with the rest of your User Interface. Agile Toolkit is in a much better position to build an ideal CRUD.

$crud $page->add('CRUD');
Name Gender Edit Delete
jjjjjhop M
aa F
aaaa F
Nikhil M

CRUD implementation in Agile Toolkit relies on other widgets such as Form, Grid, Button, Frame. Implementation is done in a classy Object-Oriented style, where you can supply your own model, change Form and Grid class, override methods, add more elements such as buttons, place multiple CRUD objects on the page and do this all with zero generated lines of code. Reloading is performed through AJAX without disturbing other elements on the page.

If you think about it — CRUD can be implemented in so many different ways and layouts and it all is very easy to achieve with the flexibility of Agile Toolkit just in a few lines of code.

Bundled Add-ons Widgets and Controllers

The Application

The web developer's lingo is messier than ever. Someone mixed up templates with views and pages with controllers. We are on the way to clean up the mess. Here is our mini glossary so far:

  • Model — Object representing real-life Entity or a person.
  • View — Object capable of displaying itself in HTML.
  • Controller — Object capable of controlling behaviour of other objects.
  • Page — Object associated with a certain URL and containing Views.
  • Application — The top-most object responsible for everything.
Page and Application haven't been discussed before. They are exactly what they seem to be. Application is responsible for delegating all functionality to other objects — accepting the request, determining corresponding Page, initializing Views and Controllers, recursively rendering your Page, adding header/footer, menu, and sending HTML to the browser.

Every time you start a new Web Application you create a new Application class by extending one of standard classes. Inside your application class you can decide what authentication to use, how to route URLs, how to connect to database and how to render menu.

class MyApp extends ApiFrontend {

There are several Application classes you can inherit from. ApiFrontend is for building your own fully-functional web applications. ApiWeb is a lightweight verison you can use from inside other frameworks. ApiCLI is an Application class for building your command-line utilities.

Your own Application class might become your own standard API class if you decide to share it and extend it across your web application.

Full Documentation on Application Classes Introduction to JavaScript and AJAX APIs