org.apache.tapestry
Class AbstractPage

java.lang.Object
  extended by org.apache.tapestry.spec.BaseLocatable
      extended by org.apache.tapestry.AbstractComponent
          extended by org.apache.tapestry.BaseComponent
              extended by org.apache.tapestry.AbstractPage
All Implemented Interfaces:
IComponent, ILocatable, ILocationHolder, IPage, IRender
Direct Known Subclasses:
BasePage, Deck

public abstract class AbstractPage
extends BaseComponent
implements IPage

Abstract base class implementing the IPage interface.

Since:
0.2.9
Version:
$Id: AbstractPage.java 243791 2004-02-19 17:38:13Z hlship $
Author:
Howard Lewis Ship, David Solis

Constructor Summary
AbstractPage()
          Standard constructor; invokes initialize() to configure initial values for properties of the page.
 
Method Summary
 void addPageDetachListener(PageDetachListener listener)
           
 void addPageRenderListener(PageRenderListener listener)
           
 void addPageValidateListener(PageValidateListener listener)
           
 void attach(IEngine value)
          Called by the engine to attach the page to itself.
 void beginPageRender()
          Invoked before a partial render of the page occurs (this happens when rewinding a Form within the page).
 void beginResponse(IMarkupWriter writer, IRequestCycle cycle)
          Deprecated. To be removed in 3.1. Implement PageRenderListener instead.
 void detach()
          Prepares the page to be returned to the pool.
 void endPageRender()
          Invoked after a partial render of the page occurs (this happens when rewinding a Form within the page).
protected  void firePageBeginRender()
           
protected  void firePageDetached()
           
protected  void firePageEndRender()
           
protected  void firePageValidate()
           
 ChangeObserver getChangeObserver()
          Return's the page's change observer.
 IEngine getEngine()
          Returns the IEngine that the page is currently attached to.
 String getExtendedId()
          Returns the name of the page.
 Object getGlobal()
          Convienience methods, simply invokes IEngine.getGlobal().
 String getIdPath()
          Pages always return null for idPath.
 Locale getLocale()
          Returns the locale for the page, which may be null if the locale is not known (null corresponds to the "default locale").
 IComponent getNestedComponent(String path)
          Returns a particular component from within the page.
protected  String getOutputEncoding()
          Returns the output encoding to be used when rendering this page.
 String getPageName()
          Returns the fully qualified name of the page, including its namespace prefix, if any.
 IRequestCycle getRequestCycle()
          Returns the current IRequestCycle.
abstract  IMarkupWriter getResponseWriter(OutputStream out)
          Implemented in subclasses to provide a particular kind of response writer (and therefore, a particular kind of content).
 Object getVisit()
          Returns the visit object obtained from the engine via IEngine.getVisit(IRequestCycle).
protected  void initialize()
          Method invoked from the constructor, and from detach() to (re-)initialize properties of the page.
 void removePageDetachListener(PageDetachListener listener)
           
 void removePageRenderListener(PageRenderListener listener)
           
 void removePageValidateListener(PageValidateListener listener)
           
 void renderPage(IMarkupWriter writer, IRequestCycle cycle)
           Invokes PageRenderListener.pageBeginRender(PageEvent) Invokes beginResponse(IMarkupWriter, IRequestCycle) Invokes IRequestCycle.commitPageChanges() (if not rewinding) Invokes AbstractComponent.render(IMarkupWriter, IRequestCycle) Invokes PageRenderListener.pageEndRender(PageEvent) (this occurs even if a previous step throws an exception)
 void setChangeObserver(ChangeObserver value)
           
 void setLocale(Locale value)
          Updates the page's locale.
 void setPageName(String pageName)
          Sets the name of the page.
 void setRequestCycle(IRequestCycle value)
          Invoked by the IRequestCycle to inform the page of the cycle, as it is loaded.
 void validate(IRequestCycle cycle)
          By default, pages are not protected and this method does nothing.
 
Methods inherited from class org.apache.tapestry.BaseComponent
addOuter, finishLoad, renderComponent
 
Methods inherited from class org.apache.tapestry.AbstractComponent
addAsset, addBody, addComponent, cleanupAfterRender, finishLoad, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, format, format, format, format, formatString, formatString, formatString, formatString, generateAttributes, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getBody, getBodyCount, getComponent, getComponents, getContainer, getId, getListeners, getMessage, getMessages, getNamespace, getPage, getProperty, getSpecification, getString, pageEndRender, prepareForRender, render, renderBody, renderInformalParameters, setBinding, setContainer, setId, setNamespace, setPage, setProperty, setSpecification, toString
 
Methods inherited from class org.apache.tapestry.spec.BaseLocatable
getLocation, setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.tapestry.IComponent
addAsset, addBody, addComponent, finishLoad, getAsset, getAssets, getBinding, getBindingNames, getBindings, getComponent, getComponents, getContainer, getId, getMessage, getMessages, getNamespace, getPage, getProperty, getSpecification, getString, renderBody, setBinding, setContainer, setId, setNamespace, setPage, setProperty, setSpecification
 
Methods inherited from interface org.apache.tapestry.IRender
render
 
Methods inherited from interface org.apache.tapestry.ILocationHolder
setLocation
 
Methods inherited from interface org.apache.tapestry.ILocatable
getLocation
 

Constructor Detail

AbstractPage

public AbstractPage()
Standard constructor; invokes initialize() to configure initial values for properties of the page.

Since:
2.2
Method Detail

getResponseWriter

public abstract IMarkupWriter getResponseWriter(OutputStream out)
Implemented in subclasses to provide a particular kind of response writer (and therefore, a particular kind of content).

Specified by:
getResponseWriter in interface IPage

detach

public void detach()
Prepares the page to be returned to the pool.

Subclasses may override this method, but must invoke this implementation (usually, last).

Specified by:
detach in interface IPage
See Also:
IPageSource.releasePage(IPage)

initialize

protected void initialize()
Method invoked from the constructor, and from detach() to (re-)initialize properties of the page. This is most useful when properties have non-null initial values.

Subclasses may override this implementation (which is empty).

Since:
2.2

getEngine

public IEngine getEngine()
Description copied from interface: IPage
Returns the IEngine that the page is currently attached to.

Specified by:
getEngine in interface IPage

getChangeObserver

public ChangeObserver getChangeObserver()
Description copied from class: AbstractComponent
Return's the page's change observer. In practical terms, this will be an IPageRecorder.

Specified by:
getChangeObserver in interface IPage
Overrides:
getChangeObserver in class AbstractComponent
See Also:
IPage.getChangeObserver()

getExtendedId

public String getExtendedId()
Returns the name of the page.

Specified by:
getExtendedId in interface IComponent
Overrides:
getExtendedId in class AbstractComponent
See Also:
AbstractComponent.getIdPath()

getIdPath

public String getIdPath()
Pages always return null for idPath.

Specified by:
getIdPath in interface IComponent
Overrides:
getIdPath in class AbstractComponent
See Also:
IComponent.getId()

getLocale

public Locale getLocale()
Returns the locale for the page, which may be null if the locale is not known (null corresponds to the "default locale").

Specified by:
getLocale in interface IPage

setLocale

public void setLocale(Locale value)
Description copied from interface: IPage
Updates the page's locale. This is write-once, a subsequent attempt will throw an ApplicationRuntimeException.

Specified by:
setLocale in interface IPage

getNestedComponent

public IComponent getNestedComponent(String path)
Description copied from interface: IPage
Returns a particular component from within the page. The path is a dotted name sequence identifying the component. It may be null in which case the page returns itself.

Specified by:
getNestedComponent in interface IPage

attach

public void attach(IEngine value)
Called by the engine to attach the page to itself. Does not change the locale, but since a page is selected from the IPageSource pool based on its locale matching the engine's locale, they should match anyway.

Specified by:
attach in interface IPage

renderPage

public void renderPage(IMarkupWriter writer,
                       IRequestCycle cycle)

setChangeObserver

public void setChangeObserver(ChangeObserver value)
Specified by:
setChangeObserver in interface IPage

setPageName

public void setPageName(String pageName)
Description copied from interface: IPage
Sets the name of the page.

Specified by:
setPageName in interface IPage
Parameters:
pageName - fully qualified page name (including namespace prefix, if any)
Since:
3.0

validate

public void validate(IRequestCycle cycle)
By default, pages are not protected and this method does nothing.

Specified by:
validate in interface IPage

beginResponse

public void beginResponse(IMarkupWriter writer,
                          IRequestCycle cycle)
Deprecated. To be removed in 3.1. Implement PageRenderListener instead.

Does nothing, subclasses may override as needed.

Specified by:
beginResponse in interface IPage

getRequestCycle

public IRequestCycle getRequestCycle()
Description copied from interface: IPage
Returns the current IRequestCycle. This is set when the page is loaded (or obtained from the pool) and attached to the engine.

Specified by:
getRequestCycle in interface IPage

setRequestCycle

public void setRequestCycle(IRequestCycle value)
Description copied from interface: IPage
Invoked by the IRequestCycle to inform the page of the cycle, as it is loaded.

Specified by:
setRequestCycle in interface IPage

getVisit

public Object getVisit()
Returns the visit object obtained from the engine via IEngine.getVisit(IRequestCycle).

Specified by:
getVisit in interface IPage

getGlobal

public Object getGlobal()
Convienience methods, simply invokes IEngine.getGlobal().

Specified by:
getGlobal in interface IPage
Since:
2.3

addPageDetachListener

public void addPageDetachListener(PageDetachListener listener)
Specified by:
addPageDetachListener in interface IPage

addPageRenderListener

public void addPageRenderListener(PageRenderListener listener)
Specified by:
addPageRenderListener in interface IPage

firePageDetached

protected void firePageDetached()
Since:
1.0.5

firePageBeginRender

protected void firePageBeginRender()
Since:
1.0.5

firePageEndRender

protected void firePageEndRender()
Since:
1.0.5

removePageDetachListener

public void removePageDetachListener(PageDetachListener listener)
Specified by:
removePageDetachListener in interface IPage
Since:
2.1-beta-2

removePageRenderListener

public void removePageRenderListener(PageRenderListener listener)
Specified by:
removePageRenderListener in interface IPage

beginPageRender

public void beginPageRender()
Description copied from interface: IPage
Invoked before a partial render of the page occurs (this happens when rewinding a Form within the page). The page is expected to fire appopriate events.

Specified by:
beginPageRender in interface IPage
Since:
2.2

endPageRender

public void endPageRender()
Description copied from interface: IPage
Invoked after a partial render of the page occurs (this happens when rewinding a Form within the page). The page is expected to fire appropriate events.

Specified by:
endPageRender in interface IPage
Since:
2.2

getPageName

public String getPageName()
Description copied from interface: IPage
Returns the fully qualified name of the page, including its namespace prefix, if any.

Specified by:
getPageName in interface IPage
Since:
3.0

addPageValidateListener

public void addPageValidateListener(PageValidateListener listener)
Specified by:
addPageValidateListener in interface IPage

removePageValidateListener

public void removePageValidateListener(PageValidateListener listener)
Specified by:
removePageValidateListener in interface IPage

firePageValidate

protected void firePageValidate()

getOutputEncoding

protected String getOutputEncoding()
Returns the output encoding to be used when rendering this page. This value is usually cached from the Engine.

Since:
3.0