org.barracudamvc.core.event.helper
Class DefaultViewHandler

java.lang.Object
  extended byorg.barracudamvc.core.event.DefaultBaseEventListener
      extended byorg.barracudamvc.core.event.helper.DefaultViewHandler
All Implemented Interfaces:
BaseEventListener, EventListener
Direct Known Subclasses:
AbstractPage, BTemplateViewHandler, ModifyDomViewHandler

public abstract class DefaultViewHandler
extends DefaultBaseEventListener

A very simple view handler that provides a default implementation tailored for the use of components. In many ways, this is analagous to the ComponentGateway class--a component hierarchy is created, initialized and rendered automatically for you. All the developer has to do is a) implement the handleViewEvent method to add any custom components to the root component (ie. for rendering) and b) return the master DOM page that needs to be rendered to generate the final view.


Field Summary
protected  boolean recycleChildren
           
protected  ViewContext vc
           
 
Fields inherited from class org.barracudamvc.core.event.DefaultBaseEventListener
idStr, localLogger
 
Constructor Summary
DefaultViewHandler()
          Public noargs constructor
 
Method Summary
 void cleanup()
          The purpose of this method is to allow for optional cleanup after all rendering is complete.
 DOMWriter getDOMWriter()
          Get a DOMWriter.
 BlockIterator getIterator(String key)
          Get a block iterator (optional)
 ViewContext getViewContext()
          Get the view context
abstract  Document handleViewEvent(BComponent root)
          Handle a view event.
 void handleViewEvent(ViewEventContext vec)
          Handle the ViewEvent
 void postCompRender(BComponent root)
          The purpose of this method is to allow for optional post-component-render cycle processing (ie. to remove a value from the user's session).
 void preCompRender(BComponent root)
          The purpose of this method is to allow for optional pre-component-render cycle processing (ie. to stick a value in the user's session).
 void setViewContext(ViewContext ivc)
          Set the view context
 
Methods inherited from class org.barracudamvc.core.event.DefaultBaseEventListener
getListenerID, handleControlEvent, handleEvent, handleOtherEvent, isHandled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

recycleChildren

protected boolean recycleChildren

vc

protected ViewContext vc
Constructor Detail

DefaultViewHandler

public DefaultViewHandler()
Public noargs constructor

Method Detail

handleViewEvent

public abstract Document handleViewEvent(BComponent root)
                                  throws EventException,
                                         javax.servlet.ServletException,
                                         IOException

Handle a view event. This is the method developers will typically override. The developers shaould add any components to the root component and then return the underlying DOM Document (that backs their components) so it can be rendered

Parameters:
root - the root component which will get rendered as a result of this request
Returns:
the Document to be rendered
Throws:
javax.servlet.ServletException
IOException
EventException

preCompRender

public void preCompRender(BComponent root)
The purpose of this method is to allow for optional pre-component-render cycle processing (ie. to stick a value in the user's session). If you need a reference to the view context, call getViewContext()

Parameters:
root - the root component which will get rendered as a result of this request

postCompRender

public void postCompRender(BComponent root)
The purpose of this method is to allow for optional post-component-render cycle processing (ie. to remove a value from the user's session). If you need a reference to the view context, call getViewContext()

Parameters:
root - the root component which will get rendered as a result of this request

cleanup

public void cleanup()
The purpose of this method is to allow for optional cleanup after all rendering is complete. Guaranteed to be invoked every time


getDOMWriter

public DOMWriter getDOMWriter()

Get a DOMWriter. By default, we use a DefaultDOMWriter. If you'd like to use something else, override this method.

Returns:
a DOMWriter to be used to render the DOM

setViewContext

public void setViewContext(ViewContext ivc)
Set the view context


getViewContext

public ViewContext getViewContext()
Get the view context


getIterator

public BlockIterator getIterator(String key)
Get a block iterator (optional)


handleViewEvent

public void handleViewEvent(ViewEventContext vec)
                     throws EventException,
                            javax.servlet.ServletException,
                            IOException
Handle the ViewEvent

Overrides:
handleViewEvent in class DefaultBaseEventListener
Parameters:
vec - the ViewEventContext
Throws:
EventException
javax.servlet.ServletException
IOException


Copyright © 2004 BarracudaMVC.org All Rights Reserved.