|
The Gravey 2.0 Framework and AIM RIA | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Object
|
+--GrvObject
|
+--MVCView
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.
| 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 |
<static> Object Depth
| Constructor Detail |
MVCView()
| Method Detail |
void addSubView( viewID, aView )
void block()
boolean build( optForceRebuild )
void buildHTML()
String buildHTMLstr()
boolean buildsubviews( optForceRebuild )
void clearSubViews( )
boolean contextChanged()
MVCContext currentContext()
void delSubView( viewID )
void disable( )
void draw( optForceRebuild )
String embedAttr( <String> attrID, <MVCView> view )
attrID - the identifier of the attribute
view - the attribute's subview to embed
String embedHTML( viewID, view )
MVCView embedView( viewID, view )
void enable( )
element getHook(forceReload)
MVCView getSubView( viewID )
element getWidget(forceReload)
String getWidgetID( optAttributeID )
String innerID()
boolean isVisible()
void konstructor( <String> optName, <String> optViewID, <boolean> optDisable )
optName - optional name of this instance
optViewID - optional ViewID of this instance. Note that while all views must have a view ID, they are usually assigned an ID at the point where a view is added as a subview to another view via addSubView(), embedView(), etc.
optDisable - optional "disable view" flag (default false)
boolean mustRebuild()
boolean mustRepaint()
void paint( optForceRepaint )
void paintHTML()
boolean rebuildAny()
void redraw()
void setParentView(v)
void setSubViewsVisible(v)
void setViewID(ID)
void setVisible(isVisible)
void unblock()
void updateContext()
void watchModel(<MVCModel> m )
m - the data model to "watch"
<static> void DrawRoot()
|
The Gravey 2.0 Framework and AIM RIA | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||