The Gravey Framework and RATS RIA

Class MVCView

Object
   |
   +--GrvObject
         |
         +--MVCView
Direct Known Subclasses:
MVCController, ToDoView, MVCListView, CountersView, DebugView, MVCScalarView, ComplexView, BalanceView, TransactionView, UnreconciledView, TotalsView, DataPanelView

class MVCView
extends GrvObject


This class acts as the base class for each (MVC) View.

Views are responsible for keeping up-to-date the HTML associated with a particular portion of the web page identified via a "hook" (i.e. an HTML element ID).

The view should display the current state of the data in the model(s) that it "watches". [NOTE: Views do not "subscribe" to Models and react to their individual update events because all views need to draw in a coordinated top-down fashion.]

Each View is also a container of subviews (as needed) and coordinates their layout by managing some skeleton framework HTML (e.g. tables/divs/spans/etc) to which the subviews hook and manage [I.E. the GoF Composite design pattern].

Once set up, views just react to "draw" events where they draw "this" view and then recurse thru any subviews invoking their draw method. [This is so that any elements of this view that are to be "hooks" for any subviews can be generated by this view first.]

Whenever a MVCController event causes some MVCModel to change, (and after all observing data models have finished their updates), the global "root container" view will initiate a single draw event cascade to update all Views on the page.

"Drawing" entails first looking at the appropriate data model(s) for this view and deciding whether they require "rebuilding" the HTML of this view, and if so, replacing the current HTML with newly generated HTML [via the innerHTML of the HTML Element ID associated with this view]. Then the paint() method is invoked to "decorate" the view with the model(s) current data (i.e. set any HTML attributes that need updating e.g. background color). Normally, HTML need not be constantly rebuilt, only decorated. A special case is where a container needs to rebuild its HTML, all subviews are forced to as well (even if they wouldnt normally based on the views they are watching).

The HTML (in string form) is generated by the abstract method "buildHTMLstr". The abstract method "mustRebuild" decides whether the draw event requires the HTML to be rebuilt before calling "paintHTML" (which is called if "mustRepaint").

 Subclasses of View should define/override:
   (1) buildHTML() constructs this view's HTML
 OR, use the default buildHTML which builds, via innerHTML, the
 HTML string returned from buildHTMLstr(), hence you would
 override instead:
   (1) buildHTMLstr() generates this view's HTML (as string)

   (2) paintHTML() modifies/decorates existing HTML structures
   (3) mustRepaint() decides if this view's HTML needs repainting
   (4) mustRebuild() decides if this view's HTML needs rebuilding
 The default implementation of mustRebuild() requires that
 instead of overriding mustRebuild() instead override:
   (4) currentContext() returns an MVCContext subclass object
       containing the driver information for building this view.

Version: 2.0

Author: Bruce Wallace (PolyGlotInc.com)
See:Defined in grvMVC.js


Field Summary
<static>  Object Depth
          
 
Constructor Summary
MVCView ()
           
 
Method Summary
 void addSubView( viewID, aView )
           add the specified view/ID to our subview list
 void block()
           API to block/unblock view updating (to stop redraw thrashing)
 boolean build( optForceRebuild )
           Recursively build this view and entire subview tree.
 void buildHTML()
           Build the HTML for this view.
 String buildHTMLstr()
           return an HTML string of the basic structure for this view.
 boolean buildsubviews( optForceRebuild )
           Recursively invoke build on entire subview tree.
 void clearSubViews( )
           clear the list of subviews of this view
 boolean contextChanged()
           return true iff the view context has changed
 MVCContext currentContext()
           return the current "context" of this view.
 void delSubView( viewID )
           delete the specified view from our subview list
 void disable( )
           disable this view (and hence all subviews)
 void draw( optForceRebuild )
           if enabled, cause entire subview tree to be built/painted as needed
 String embedAttr( <String> attrID, <MVCView> view )
           same as embedHTML() but auto-creates viewID and saves reference to view based on specified "attribute" ID.
 String embedHTML( viewID, view )
           same as embedView() but return the HTML string of the view rather than the View object.
 MVCView embedView( viewID, view )
           add the specified view/ID as an "embedded" subview.
 void enable( )
           enable this view (thereby enabling all enabled subviews)
 element getHook(forceReload)
           return the HTML element of this view's hook tag
 MVCView getSubView( viewID )
           find the specified view in the tree of subviews
 element getWidget(forceReload)
           return the HTML element of this view's widget tag
 String getWidgetID( optAttributeID )
           Return the effective ID of the widget for this view.
 String innerID()
           return the "inner" view ID for this view
 boolean isVisible()
           return whether this view is visible
 void konstructor( <String> optName, <String> optViewID, <boolean> optDisable )
          
 boolean mustRebuild()
           return true IFF model(s) require the HTML rebuilt for THIS view default implementation: If there is a difference in the current "build context" and the current one then rebuild else not.
 boolean mustRepaint()
           return true IFF model(s) require HTML repaint.
 void paint( optForceRepaint )
           Recursively invoke paint on entire subview tree.
 void paintHTML()
           update/modify attributes of basic existing HTML for THIS view
 boolean rebuildAny()
           does this view or any embedded subview need rebuilding?
 void redraw()
           if enabled, force a "draw" of this view (and all enabled subviews)
 void setParentView(v)
           set the parent view of this view
 void setSubViewsVisible(v)
           set all subview visiblility
 void setViewID(ID)
           (re)define the view ID for this view
 void setVisible(isVisible)
           set this view as visible or not and manifest it via the HTML.
 void unblock()
           API to block/unblock view updating (to stop redraw thrashing)
 void updateContext()
           update and save the current MVCContext for this view
 void watchModel(<MVCModel> m )
           register the given model as our primary data model
<static> void DrawRoot()
           Static method to draw the root view (and hence all views)
 
Methods inherited from class GrvObject
souper
 

Field Detail

Depth

<static> Object Depth

Constructor Detail

MVCView

MVCView()

Method Detail

addSubView

void addSubView( viewID, aView )

block

void block()

build

boolean build( optForceRebuild )

buildHTML

void buildHTML()

buildHTMLstr

String buildHTMLstr()

buildsubviews

boolean buildsubviews( optForceRebuild )

clearSubViews

void clearSubViews( )

contextChanged

boolean contextChanged()

currentContext

MVCContext currentContext()

delSubView

void delSubView( viewID )

disable

void disable( )

draw

void draw( optForceRebuild )

embedAttr

String embedAttr( <String> attrID, <MVCView> view )

embedHTML

String embedHTML( viewID, view )

embedView

MVCView embedView( viewID, view )

enable

void enable( )

getHook

element getHook(forceReload)

getSubView

MVCView getSubView( viewID )

getWidget

element getWidget(forceReload)

getWidgetID

String getWidgetID( optAttributeID )

innerID

String innerID()

isVisible

boolean isVisible()

konstructor

void konstructor( <String> optName, <String> optViewID, <boolean> optDisable )

mustRebuild

boolean mustRebuild()

mustRepaint

boolean mustRepaint()

paint

void paint( optForceRepaint )

paintHTML

void paintHTML()

rebuildAny

boolean rebuildAny()

redraw

void redraw()

setParentView

void setParentView(v)

setSubViewsVisible

void setSubViewsVisible(v)

setViewID

void setViewID(ID)

setVisible

void setVisible(isVisible)

unblock

void unblock()

updateContext

void updateContext()

watchModel

void watchModel(<MVCModel> m )

DrawRoot

<static> void DrawRoot()

The Gravey Framework and RATS RIA

Documentation generated by JSDoc on Sat Dec 8 21:52:02 2007