Widget Pages


J2EE patterns: Widget Pages

  1. Widget Pages (2 messages)

    Widget Pages

    An HTTP-Oriented MVC Pattern

    by Guilherme Gusm?o da Silva


    * HTTP request and response cycle nature impacts the MVC pattern.
    * Here we try to describe this impact.
    * Based on that description we propose an HTTP-oriented MVC pattern called Widget Pages.
    * The new MVC pattern makes extensive use of XMLC and Barracuda technologies.

    The MVC Pattern

    * MVC separates a GUI in its data (model), its appearance (view) and its algorithm (controller).

    The HTTP Protocol

    * HTTP separates a Web page in its markup representation and the corresponding Web browser GUI.

    MVC versus HTTP (I)

    * HTTP distinguishes between a markup view and a GUI view. MVC does not.
    * For the HTTP server, there is only a markup view, not a GUI view. For MVC, there is only a GUI view.
    * In the HTTP response, the markup view should also represent pure data.

    MVC versus HTTP (II)

    * A view as a GUI always represents either a valid, or a fake, or even an empty model processed by a controller. So it is also a whole MVC pattern.
    * A view as markup can also be a whole MVC pattern - a model processed by a controller.
    * However, it can exist before any controller processes any model. So it can be a pure view (for instance: <SELECT></SELECT>).

    MVC versus HTTP (III)

    * HTTP splits MVC into both a server MVC (sMVC) and a client MVC (cMVC).
    * sMVC is the model of cMVC, which is also a view based on an interpretation of sMVC by a client-side controller.
    * So sMVC is the view model of cMVC, and cMVC is the controller view of sMVC.

    The Data Concept

    * The data within the HTTP response view is the sMVC model.
    * So the sMVC model is data.

    A Controller as Data

    * The sMVC data can also be the cMVC view model (for instance: a checked radio button within a table cell).
    * To add a view model to an sMVC pure view, the HTTP server has to give a controller another controller as data.
    * So the data concept is not restricted to pure data.

    The Prototype Concept

    * The HTTP response view should incorporate data.
    * A pure, empty view to which an sMVC controller adds data is a prototype.

    An XMLC Prototype

    * XMLC generates Java classes from HTML, XML, XHTML, and WML etc.
    * In these classes, each XML tag identified by an ID attribute within the original document is a DOM node accessible by a getter method.
    * Such a DOM node is a prototype.

    The Widget Concept

    * A widget is an algorithm capable of adding data to a prototype.
    * So an sMVC controller is a widget.

    A Barracuda's Widget

    * Barracuda has components capable of adding data to prototypes.
    * For a Barracuda's component, data can be another Barracuda's component.
    * So each Barracuda's component is a widget.

    The Page Concept

    * A widget needs access to a prototype in order to add it data.
    * This access can be a Java interface getter method allowing the widget to vary its prototype providers.
    * Such a Java interface is a page.

    Multiple Page Inheritance

    * In Java, multiple inheritances are allowed within interfaces.
    * Through multiple inheritances within pages, it is possible to vary the prototypes in a Web page without changing or creating any widget.

    Widget Pages Core

    * The Widget Pages core defines five Java classes.
    * These classes include three interfaces, an abstract class and a final class.
    * In addition to depending on other Widget Pages core classes, a Widget Pages core class depends only on the Object class.
    * Now follows a description of each Widget Pages core class.


    * The Widget Pages core defines a mandatory parent class for all pages, the Page interface.
    * However, there is no Page method that gets a prototype used by all possible widgets.
    * Therefore, the Page interface has no methods.


    * The Widget Pages core defines a mandatory interface for all widgets, the Widget interface.
    * The Widget interface has five methods.
    * Now follows a description of each method of the Widget interface.


    * The Widget.getData() method returns a data object:
    * public Object getData();
    * A data object can be any object, including a Widget interface implementer.
    * So the Widget.getData() method returns an Object.


    * The Widget.getPrototype() method returns an actual prototype implementation:
    * public Object getPrototype();
    * A prototype can be any object, such as an org.w3c.dom.Element, or an org.w3c.dom.html.HTMLSelectElement.
    * So the Widget.getPrototype() method returns an Object.


    * The Widget.getWidget() method returns an actual widget implementation:
    * public Object getWidget();
    * A widget can be any object, such as a Barracuda's component.
    * So the Widget.getWidget() method returns an Object.


    * The Widget.getWidget(Object) method returns a Widget interface implementer:
    * public Widget getWidget(Object);
    * The returned widget is a clone of the invoked one whose Widget.getData() method returns the same Object received by the original widget as a parameter.
    * The returned widget is data for the invoker ones.


    * The Widget.getPage() method returns a Page interface implementer:
    * public Page getPage();
    * The returned page is a child of the Page interface used by the widget to get its prototype.


    * The Widget Pages core defines a mandatory parent class for all widgets, the PageWidget abstract class.
    * It has two constructors, one of which receives a Page interface implementer and an Object as data.
    * The PageWidget abstract class provides final implementations of three Widget methods:
    * Widget.getData()
    * Widget.getWidget(Object)
    * Widget.getPage()


    * The other constructor of the PageWidget abstract class receives a Page interface implementer, an Object as data and a WidgetDataHandler interface implementer.
    * The WidgetDataHandler interface has only one method, called within the Widget.getData() method for changing a widget data as necessary:
    * public Object getData(Object);


    * The Widget Pages core defines a default implementation of the WidgetDataHandler interface, the DefaultDataHandler final class.
    * Its WidgetDataHandler.getData(Object) method returns the same Object received as a parameter.
    * This is the class used within the Widget.getData() method when the PageWidget class two-parameter constructor is used.

    Pattern Scope

    * In addition to multiple page inheritance, the Widget Pages core applies to the full sMVC because of three methods:
    * WidgetDataHandler.getData(Object)
    * Widget.getPrototype()
    * Widget.getWidget(Object)
    * Now follows a by-method showing of it.


    * This method allows giving a widget other widgets as data.
    * So a widget (an sMVC controller) can add any view model to any prototype.


    * This method allows using the same widgets for adding data to any prototypes.
    * So the same widgets can be used within any other widgets to add data to whatever their prototypes are.


    * This method allows adding data to widgets contained in other widgets by means of the containing ones.
    * So the same widgets can be used within any other widgets whatever their data is.

    Reason For The Name

    * The proposed MVC pattern is called Widget Pages for multiple page inheritance directs it toward widget sets that are also pages, widget pages for short.

    Main Benefits

    * Rigorous isolation between the view and the controller (XMLC).
    * Truly generic controllers (Barracuda).
    * API independent of both widget and prototype implementations (Barracuda and XMLC).
    * Compile-time checking of the widget/prototype contract (XML ID tags).
    * Optimized access to prototypes (XMLC-generated DOM node getters).


    * XMLC (http://xmlc.enhydra.org).
    * Barracuda (http://barracuda.enhydra.org).
    * XML Journal article "Enhydra Design Patterns for ASPs" by Nick Xidis (http://www.sys-con.com/xml/article.cfm?id=340).

    Threaded Messages (2)

  2. Widget Pages[ Go to top ]

    Do you mean HTML or *ML rather than HTTP. HTTP is a protocol.
  3. Widget Pages[ Go to top ]

    Do you mean HTML or *ML rather than HTTP. HTTP is a protocol.