net.sourceforge.stripes.tag.layout
Class LayoutComponentRenderer

java.lang.Object
  extended by net.sourceforge.stripes.tag.layout.LayoutComponentRenderer

public class LayoutComponentRenderer
extends Object

An object that can be stuffed into a scope (page, request, application, etc.) and render a layout component to a string. This allows for use of EL expressions to output a component (as described in the book Stripes ... and web development is fun again) without requiring that all components be evaluated and buffered just in case a string representation is needed. The evaluation happens only when necessary, saving cycles and memory.

When toString() is called, the component renderer will evaluate the body of any LayoutComponentTag found in the stack of LayoutContexts maintained in the JSP PageContext having the same name as that passed to the constructor. The page context must be provided with a call to pushPageContext(PageContext) for the renderer to work correctly.

Since:
Stripes 1.5.4
Author:
Ben Gunter

Constructor Summary
LayoutComponentRenderer(String component)
          Create a new instance to render the named component to a string.
 
Method Summary
 String getCurrentPage()
          Get the path to the currently executing JSP.
 PageContext getPageContext()
          Get the last page context that was pushed onto the stack.
 PageContext popPageContext()
          Pop the last page context off the stack and return it.
 void pushPageContext(PageContext pageContext)
          Push a new page context onto the page context stack.
 String toString()
          Open a buffer in LayoutWriter, call write() to render the component and then return the buffer contents.
 boolean write()
          Write the component to the page context's writer, optionally buffering the output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LayoutComponentRenderer

public LayoutComponentRenderer(String component)
Create a new instance to render the named component to a string.

Parameters:
component - The name of the component to render.
Method Detail

pushPageContext

public void pushPageContext(PageContext pageContext)
Push a new page context onto the page context stack. The last page context pushed onto the stack is the one that will be used to evaluate the component tag's body.


popPageContext

public PageContext popPageContext()
Pop the last page context off the stack and return it.


getPageContext

public PageContext getPageContext()
Get the last page context that was pushed onto the stack.


getCurrentPage

public String getCurrentPage()
Get the path to the currently executing JSP.


write

public boolean write()
              throws ServletException,
                     IOException
Write the component to the page context's writer, optionally buffering the output.

Returns:
True if the named component was found and it indicated that it successfully rendered; otherwise, false.
Throws:
IOException - If thrown by LayoutContext.doInclude(PageContext, String)
ServletException - If thrown by LayoutContext.doInclude(PageContext, String)

toString

public String toString()
Open a buffer in LayoutWriter, call write() to render the component and then return the buffer contents.

Overrides:
toString in class Object


© Copyright 2005-2006, Stripes Development Team.