YOUR FEEDBACK
Immo Huneke wrote: A well written article, an ingenious solution to a real problem often encountere...
Cloud Computing Conference
March 30 - April 1, New York
Register Today and SAVE !..

SYS-CON.TV

2008 East
DIAMOND SPONSOR:
Data Direct
Frontiers in Data Access: The Coming Wave in Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
Intel
Virtualization – Path to Predictive Enterprise
Green Hills
IT Security in a Hostile World
JBoss / freedom oss
Practical SOA Approach
GOLD SPONSORS:
Software AG
The Art & Science of SOA: How Governance Enables Adoption
PlateSpin
Effective Planning for Virtual Infrastructure Growth
Fujitsu
Automated Business Process Discovery & Virtualization Service
Ceedo
Workspace Virtualization
Click For 2007 West
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
TOP THREE LINKS YOU MUST CLICK ON


AJAX Book Preview: "Controller"
A component class abstracts some behavior and to implement that, it might add a set of event listeners to its elements

This content is reprinted from Real-World AJAX: Secrets of the Masters published by SYS-CON Books. To order the entire book now along with companion DVDs for the special pre-order price, click here for more information. Aimed at everyone from enterprise developers to self-taught scripters, Real-World AJAX: Secrets of the Masters is the perfect book for anyone who wants to start developing AJAX applications.

Controller
In the previous section we discussed a set of abstractions that are sub-classes of the component. A component class abstracts some behavior and to implement that, it might add a set of event listeners to its elements. Those event handlers are encapsulated in the component class and serves as its controllers. But in a bigger scheme of things, they are fully contained in the component class and can be considered a part of the View.

Besides component-specific listeners, there is a set of application-specific event listeners that respond to user inputs or timer events. These are called controllers. An event handler is a trigger point for some behavior implemented by the rest of the controller. This behavior can commonly be categorized as follows.

  1. Controllers that simply change the state of the view such as color, enabled/disabled, hide/visible, and font based on some application logic.
  2. Controllers that trigger re-rendering of the UI or its part due to some data change or navigation.
  3. Controllers that execute some business logic or do computation. Here you need to worry about the security issues based on other parameters such as if the application is running over an intranet or Internet. Based on such parameters, the business logic can be executed in the browser space or delegated to the server. In almost all cases, if some other data look-up is needed, then it's recommended that the task be delegated to a back-end service through the controller servlet.
  4. Controllers that fetch data from the back-end server, update the client model, and send a trigger to the View for re-rendering data.
  5. Timer controllers that do something periodically. For example, a timer can periodically check for the availability of new updates on the server.
Controllers encapsulate application logic-specific details. Some of these details can be abstracted as base classes in the application code. We'll visit some of these controllers in the context of an application in the following sections.

MVC Interaction
We've described the Model, View, and Controller components of the MVC pattern. Now let's consider a typical sequence of operations on the client side to understand the interactions among them better.

  • As a result of access to a URL by the user, the browser downloads a page and triggers the execution of certain controller code due to its "onload" event.
  • In the first step, the controller retrieves the HTML template from the server using an AJAX call.
  • Next the controller retrieves data from the server using an AJAX call and inserts it into the cache.
  • Then the controller instantiates one or more components, creating an association between the components and HTML elements.
  • To populate the data, the controller invokes a "setValue" call on one or more components.
  • Lastly, the controller adds application-specific event handlers to the elements.

This content is reprinted from Real-World AJAX: Secrets of the Masters published by SYS-CON Books. To order the entire book now along with companion DVDs, click here to order.

About Anil Sharma
Anil Sharma is a founder of Vertex Logic and architect of its AjaxFace product. He is working with Vertex Logic's customers and helping them deploy WEB 2.0 applications built using AjaxFace. These applications are in the areas of online printing, community WEB sites and social networking. He is driving future products of Vertex Logic. Prior to Vertex Logic, he was CTO and founder of Softrock Systems and Component Plus. There he built a model driven application platform using J2EE. His primary interests include user interface infrastructures and model driven applications. He is one of the contributors of the book "Real World AJAX - Secrets of the Master".

LATEST AJAXWORLD RIA STORIES
Curl announced the release of Curl Data Kit Data Services (CDK-DS) for enterprise developers building new applications using Adobe Flex or Flash, as well as developers upgrading existing Curl applications. This addition to the Curl Rich Internet Application (RIA) Platform is an i...
rPath and WANdisco today announced that WANdisco has selected the rPath rBuilder and rPath Lifecycle Management Platform to build and maintain its Subversion MultiSite solution as a manageable set of application images for delivery in virtualized and cloud-based environments. rPa...
MuleSource has announced a partnership with FastConnect that will provide Mule architecture and implementation services throughout the French market. FastConnect spans the domains of data and service integration, through to the user interface, using technologies such as SOA, dist...
Adobe and Intel plan to collaborate on porting Adobe’s Flash widgetry to Intel’s Media Processor CE 3100, a way to put Flash-enhanced web content and rich Flash applications on television. The chip is bound for cable set-top boxes, Blu-ray Disc players, digital TVs and retail...
Here, SYS-CON's Web 2.0 Journal has asked a selection of the industry's brightest minds what their own advice would be in these troubled times, and assembled it into a ten-point guide for software vendors, entrepreneurs, and startups to riding out a recession.
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

Click Here

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE