Project Documentation

Summary

Tag name: <t:buffer>
UIComponent class: org.apache.myfaces.custom.buffer.Buffer
Tag class: org.apache.myfaces.custom.buffer.BufferTag
Component type: org.apache.myfaces.Buffer
Component family: javax.faces.Data
Renderer type: org.apache.myfaces.Buffer
Renderer class: org.apache.myfaces.custom.buffer.BufferRenderer

A component that renders its child components into an in-memory buffer rather than render them directly to the response stream.

Property "into" is an EL expression that specifies where to store a String holding the results of rendering all the children of this component; this is assigned to after rendering of this component (and its children) is complete.

Typically, an h:output tag is then used later in the same page to output the buffer contents.

This can be useful with JSF1.1/JSP2.0 to work around the well-known problem where on first render of a page, a component "A" cannot reference a component "B" which is defined later in the page because it has not yet been created. A solution is to define "B" before "A", but wrapped in a Buffer component. Component A can then be rendered and successfully reference "B" because it now exists. And later in the page, the buffer contents can then be output, preserving the original layout.

This can also be useful when rendering the same data block multiple times within a page. For example, a datatable can be rendered with a datascroller both before and after it; first render the table into a buffer B1, then render the datascroller into a buffer B2, then output buffers B2,B1,B2.

Usage

<t:buffer into="Bean">
    <t:div>
        <h:outputText value="String"/>
    </t:div>
</t:buffer>

Instructions

Just nest elements to buffer into a \<t:buffer\> element.

See examples/buffer.jsp for an example!

Attributes

Name Type Supports EL? Description
into String Yes An EL expression that specifies where to store a String holding the results of rendering all the children of this component; this is assigned to after rendering of this component (and its children) is complete.