com.sun.rave.web.ui.component.util.descriptors
Class LayoutForEach

java.lang.Object
  extended by com.sun.rave.web.ui.component.util.descriptors.LayoutElementBase
      extended by com.sun.rave.web.ui.component.util.descriptors.LayoutForEach
All Implemented Interfaces:
LayoutElement, java.io.Serializable

public class LayoutForEach
extends LayoutElementBase
implements LayoutElement

This class defines a LayoutForEach LayoutElement. The LayoutForEach provides the functionality necessary to iteratively display a portion of the layout tree. The list property contains the List of items to iterate over.

See Also:
VariableResolver, Serialized Form

Field Summary
static java.lang.String AFTER_LOOP
           This is the event "type" for Handler elements to be invoked after this LayoutForEach is processed (outside loop).
static java.lang.String BEFORE_LOOP
           This is the event "type" for Handler elements to be invoked before this LayoutForEach is processed (outside loop).
 
Fields inherited from class com.sun.rave.web.ui.component.util.descriptors.LayoutElementBase
AFTER_ENCODE, BEFORE_ENCODE, ENCODE
 
Constructor Summary
LayoutForEach(LayoutElement parent, java.lang.String listBinding, java.lang.String key)
          Constructor.
 
Method Summary
 void encode(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           This implementation overrides the parent encode method.
protected  boolean encodeThis(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           This method always returns true.
protected  java.util.List getList(javax.faces.context.FacesContext context)
           This method evaluates the list binding for this LayoutForEach.
protected  void setCurrentForEachValue(javax.faces.context.FacesContext context, java.lang.Object value, int index, java.lang.String key)
           This method sets the Object that is currently being processed by this LayoutForEach.
 
Methods inherited from class com.sun.rave.web.ui.component.util.descriptors.LayoutElementBase
addChildLayoutElement, createHandlerContext, dispatchHandlers, dispatchHandlers, encodeChild, getChildLayoutElements, getHandlers, getHandlers, getHandlersByTypeMap, getId, getLayoutDefinition, getParent, getUnevaluatedId, resolveValue, setHandlers, setHandlersByTypeMap, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.rave.web.ui.component.util.descriptors.LayoutElement
addChildLayoutElement, dispatchHandlers, dispatchHandlers, getChildLayoutElements, getHandlers, getId, getLayoutDefinition, getParent, getUnevaluatedId, setHandlers
 

Field Detail

AFTER_LOOP

public static final java.lang.String AFTER_LOOP

This is the event "type" for Handler elements to be invoked after this LayoutForEach is processed (outside loop).

See Also:
Constant Field Values

BEFORE_LOOP

public static final java.lang.String BEFORE_LOOP

This is the event "type" for Handler elements to be invoked before this LayoutForEach is processed (outside loop).

See Also:
Constant Field Values
Constructor Detail

LayoutForEach

public LayoutForEach(LayoutElement parent,
                     java.lang.String listBinding,
                     java.lang.String key)
Constructor.

Parameters:
parent - The parent LayoutElement
listBinding - The List to iterate over
key - The ServletRequest attribute key used to store the object being processed
Method Detail

encodeThis

protected boolean encodeThis(javax.faces.context.FacesContext context,
                             javax.faces.component.UIComponent component)

This method always returns true. The condition is based on an Iterator.hasNext() call instead of here because the #encode(FacesContext, TemplateComponent) method evaluates this and then calls the super. Performing the check here would cause the condition to be evaluated twice.

Specified by:
encodeThis in class LayoutElementBase
Parameters:
context - The FacesContext
component - The UIComponent
Returns:
true

getList

protected java.util.List getList(javax.faces.context.FacesContext context)

This method evaluates the list binding for this LayoutForEach. This is expected to evaulate to a List object. If it doesn't, this method will throw a NullPointerException (if it evaulates to null), or an IllegalArgumentException if it doesn't evaluate to a List.

Parameters:
context - The FacesContext return The List of objects to iterate over

setCurrentForEachValue

protected void setCurrentForEachValue(javax.faces.context.FacesContext context,
                                      java.lang.Object value,
                                      int index,
                                      java.lang.String key)

This method sets the Object that is currently being processed by this LayoutForEach. This implementation stores this value in the request attribute map undert the key provided to this LayoutForEach.

As an added convenience, this method will also set an attribute that contains the current index number. The attribute key will be the same key the Object is stored under plus "-index". The index is stored as a String.

Parameters:
context - The FacesContext
value - The Object to store
index - The current index number of the Object

encode

public void encode(javax.faces.context.FacesContext context,
                   javax.faces.component.UIComponent component)
            throws java.io.IOException

This implementation overrides the parent encode method. It does this to cause the encode process to loop as long as there are more List entries to process.

Specified by:
encode in interface LayoutElement
Overrides:
encode in class LayoutElementBase
Parameters:
context - The FacesContext
component - The UIComponent
Throws:
java.io.IOException