Miscellaneous Code

  Home arrow Miscellaneous Code arrow Filtering Input Data and Generating HT...
MISCELLANEOUS CODE

Filtering Input Data and Generating HTML Forms with the HMVC Design Pattern
By: Alejandros Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2010-03-10

    Table of Contents:
  • Filtering Input Data and Generating HTML Forms with the HMVC Design Pattern
  • Review: a quick look at the MySQL and cache classes
  • Filtering user-supplied data with a simple input-handling class
  • Building an HTML form helper

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Filtering Input Data and Generating HTML Forms with the HMVC Design Pattern


    (Page 1 of 4 )

    In this fourth part of a nine-part series you will learn how to extend the existing functionality of the HMVC-based framework we're building. Specifically, we're going to add a pair of classes to it that permit you to perform basic sanitation on incoming data and generate simple HTML forms.

    The Model-View-Controller design pattern is one of the most efficient paradigms that can be used nowadays for developing web-based programs that maintain their business and application logic isolated from the layer that deals with visual presentation. The schema imposed by this pattern, however, can be taken one step further through a hierarchical usage of it.

    Yes, as you may have heard, there exists another design pattern, not surprisingly called Hierarchical Model-View-Controller, which can be considered an “enhancement” of a regular MVC implementation. It allows you to build applications composed of multiple and independent MVC modules, also commonly known as MVC triads.       

    Essentially, during the normal cycle of operation of a program that uses the MVC design pattern, each HTTP request is routed and dispatched to a single controller, which eventually will invoke one or multiple models and views, thus completing the cycle. However, when the HMVC pattern is used, a single request can produce calls to isolated modules composed themselves of a controller, a model and a view, or in other words, the aforementioned MVC triads.

    This hierarchical approach permits you to create applications that are much more modular and flexible than the ones developed using a typical MVC layer, although as with many other design patterns, its implementation in real-world projects isn’t mandatory at all.

    Of course, there are many approaches that can be taken to learn how to apply the HMVC paradigm, especially when using PHP 5. But in this particular case, I decided to take one that will demonstrate the use of the pattern through the development of a small, object-oriented framework. To accomplish this goal, in previous chapters of this series I added some core components to this framework, including a front controller and a dispatcher, a request-handling module (this is actually the one that makes it easy to handle MVC triads), and a caching class.

    However, to illustrate more precisely how to use the HMVC paradigm with this sample framework it’s necessary to make it a bit more functional. Therefore, in this article I’m going to code a couple of classes that will take care of filtering user-supplied data and helping in the generation of HTML forms.

    Now, to learn how these new classes will be created, click on the link below and start reading!

    More Miscellaneous Code Articles
    More By Alejandros Gervasio

    blog comments powered by Disqus

    MISCELLANEOUS CODE ARTICLES

    - Creating a Web Page Controller with the HMVC...
    - Coding Controllers and Views for the HMVC De...
    - A Sample Web Application with the HMVC Desig...
    - Adding a Class to Parse Views to an HMVC Des...
    - Building a Model Class for the HMVC Design P...
    - Filtering Input Data and Generating HTML For...
    - The HMVC Design Pattern: Working with MySQL ...
    - Dispatching Requests to MVC Triads with the ...
    - Implementing the Hierarchical Model-View-Con...
    - A Web App Based on a Model for the CodeIgnit...
    - Completing a Model for the CodeIgniter PHP F...
    - Validating Input Data with the CodeIgniter P...
    - Deleting Database Records with the CodeIgnit...
    - Inserting Database Records with a CodeIgnite...
    - Fetching Database Rows with a Model for the ...

    Developer Shed Affiliates

     



    © 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap