FileDocCategorySizeDatePackage
BarRenderer.javaAPI DocExample3173Tue Jun 08 11:26:42 BST 2004com.mycompany.jsf.renderer

BarRenderer

public class BarRenderer extends javax.faces.render.Renderer
This class is a JSF Renderer for the "javax.faces.Data" component type.
author
Hans Bergsten, Gefion Software
version
1.0

Fields Summary
Constructors Summary
Methods Summary
public voidencodeChildren(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
Renders the component by letting its UIColumn children process one row at a time, starting with the row specified by the "first" attribute for the number of rows specified by the "rows" attribute, or until the lasy row is reached. If an explicit ID is set for the component, the component's client ID value is used as the "id" attribute value on a "span" element that wraps all output produced by the children.


        if (!component.isRendered()) {
            return;
        }

	String clientId = null;
	if (component.getId() != null && 
	    !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) {
	    clientId = component.getClientId(context);
	}

        ResponseWriter out = context.getResponseWriter();
	if (clientId != null) {
	    out.startElement("span", component);
	    out.writeAttribute("id", clientId, "id");
	}

        UIData data = (UIData) component;

        int first = data.getFirst();
        int rows = data.getRows();
        for (int i = first, n = 0; rows == 0 || n < rows; i++, n++) {
            data.setRowIndex(i);
            if (!data.isRowAvailable()) {
                break;
            }

	    Iterator j = data.getChildren().iterator();
	    while (j.hasNext()) {
		UIComponent column = (UIComponent) j.next();
		if (!(column instanceof UIColumn)) {
		    continue;
		}
		encodeRecursive(context, column);
	    }
	}

	if (clientId != null) {
            out.endElement("span");
	}
    
private voidencodeRecursive(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
Calls the appropriate encoding methods on the component and calls itself recursively for all component children.


        if (!component.isRendered()) {
            return;
        }

        component.encodeBegin(context);
        if (component.getRendersChildren()) {
            component.encodeChildren(context);
        } else {
            Iterator i = component.getChildren().iterator();
            while (i.hasNext()) {
                UIComponent child = (UIComponent) i.next();
                encodeRecursive(context, child);
            }
        }
        component.encodeEnd(context);
    
public booleangetRendersChildren()
Returns "true".

	return true;