java.lang.Object
org.apache.tapestry.components.BlockRenderer
- All Implemented Interfaces:
- org.apache.tapestry.IRender
- public class BlockRenderer
- extends java.lang.Object
- implements org.apache.tapestry.IRender
An implementation of IRender that renders a Block component.
The BlockRenderer allows the contents of a Block to be rendered
via org.apache.tapestry.IRender. It can be used in cases when an org.apache.tapestry.IRender object is
required as an argument or a binding to render a part of a Component.
To provide a complicated view, it could be defined in a Block and then
returned encapsulated in a BlockRenderer.
It is important to note that a special care has to be taken if
the BlockRenderer is used within an inner class of a component or a page.
In such a case the instance of the component that created the inner class
may not be the currently active instance in the RequestCycle when the
BlockRenderer is required. Thus, calling getComponent("blockName") to get the
block component may return a Block component that is not initialized for this
RequestCycle.
To avoid similar problems, the ComponentAddress class could be used in
conjunction with BlockRenderer.
Here is a quick example of how BlockRenderer could be used with ComponentAddress:
// Create a component address for the current component
final ComponentAddress address = new ComponentAddress(this);
return new SomeClass() {
IRender getRenderer(IRequestCycle cycle) {
MyComponent component = (MyComponent) address.findComponent(cycle);
// initialize variables in the component that will be used by the block here
return new BlockRenderer(component.getComponent("block"));
}
}
- Since:
- 2.2
|
Constructor Summary |
BlockRenderer(Block objBlock)
Creates a new BlockRenderer that will render the content of the argument |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
__CLOVER_62_0
public static com.cortexeb.tools.clover.d __CLOVER_62_0
m_objBlock
private Block m_objBlock
BlockRenderer
public BlockRenderer(Block objBlock)
- Creates a new BlockRenderer that will render the content of the argument
render
public void render(org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.IRequestCycle cycle)
- Description copied from interface:
org.apache.tapestry.IRender
- The principal rendering/rewinding method. This will cause
the receiving component to render its top level elements (HTML
text and components).
Renderring and rewinding are the exact same process. The
same code that renders must be able to restore state by going
through the exact same operations (even though the output is
discarded).
- Specified by:
render in interface org.apache.tapestry.IRender