Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   *
   * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
   *
   * The contents of this file are subject to the terms of either the GNU
   * General Public License Version 2 only ("GPL") or the Common Development
   * and Distribution License("CDDL") (collectively, the "License").  You
   * may not use this file except in compliance with the License.  You can
  * obtain a copy of the License at
  * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
  * or packager/legal/LICENSE.txt.  See the License for the specific
  * language governing permissions and limitations under the License.
  *
  * When distributing the software, include this License Header Notice in each
  * file and include the License file at packager/legal/LICENSE.txt.
  *
  * GPL Classpath Exception:
  * Oracle designates this particular file as subject to the "Classpath"
  * exception as provided by Oracle in the GPL Version 2 section of the License
  * file that accompanied this code.
  *
  * Modifications:
  * If applicable, add the following below the License Header, with the fields
  * enclosed by brackets [] replaced by your own identifying information:
  * "Portions Copyright [year] [name of copyright owner]"
  *
  * Contributor(s):
  * If you wish your version of this file to be governed by only the CDDL or
  * only the GPL Version 2, indicate your decision by adding "[Contributor]
  * elects to include this software in this distribution under the [CDDL or GPL
  * Version 2] license."  If you don't indicate a single choice of license, a
  * recipient has the option to distribute your version of this file under
  * either the CDDL, the GPL Version 2 or to extend the choice of license to
  * its licensees as provided above.  However, if you add GPL Version 2 code
  * and therefore, elected the GPL Version 2 license, then the option applies
  * only if the new code is made subject to such option by the copyright
  * holder.
  */
 
 package javax.faces.render;
 
 

A Renderer converts the internal representation of javax.faces.component.UIComponents into the output stream (or writer) associated with the response we are creating for a particular request. Each Renderer knows how to render one or more javax.faces.component.UIComponent types (or classes), and advertises a set of render-dependent attributes that it recognizes for each supported javax.faces.component.UIComponent.

Families of Renderers are packaged as a RenderKit, and together support the rendering of all of the javax.faces.component.UIComponents in a view associated with a javax.faces.context.FacesContext. Within the set of Renderers for a particular RenderKit, each must be uniquely identified by the rendererType property.

Individual Renderer instances will be instantiated as requested during the rendering process, and will remain in existence for the remainder of the lifetime of a web application. Because each instance may be invoked from more than one request processing thread simultaneously, they MUST be programmed in a thread-safe manner.

If the javax.faces.event.ListenerFor annotation is attached to the class definition of a Renderer, that class must also implement javax.faces.event.ComponentSystemEventListener, and the action pertaining to the processing of ResourceDependency on a Renderer described in javax.faces.event.ListenerFor must be taken.

If the javax.faces.application.ResourceDependency annotation is attached to the class definition of a Renderer, the action pertaining to the processing of ResourceDependency on a Renderer described in javax.faces.component.UIComponent.getChildren() must be taken.

 
 
 public abstract class Renderer {
     
     
     // ------------------------------------------------------ Rendering Methods
 

    

Decode any new state of the specified javax.faces.component.UIComponent from the request contained in the specified javax.faces.context.FacesContext, and store that state on the javax.faces.component.UIComponent.

During decoding, events may be enqueued for later processing (by event listeners that have registered an interest), by calling queueEvent() on the associated javax.faces.component.UIComponent.

Parameters:
context javax.faces.context.FacesContext for the request we are processing
component javax.faces.component.UIComponent to be decoded.
Throws:
java.lang.NullPointerException if context or component is null
    public void decode(FacesContext contextUIComponent component) {
	if (null == context || null == component) {
	    throw new NullPointerException();
	}
    }


    

Render the beginning specified javax.faces.component.UIComponent to the output stream or writer associated with the response we are creating. If the conversion attempted in a previous call to getConvertedValue() for this component failed, the state information saved during execution of decode() should be used to reproduce the incorrect input.

Parameters:
context javax.faces.context.FacesContext for the request we are processing
component javax.faces.component.UIComponent to be rendered
Throws:
java.io.IOException if an input/output error occurs while rendering
java.lang.NullPointerException if context or component is null
    public void encodeBegin(FacesContext context,
			    UIComponent component)
        throws IOException {
	if (null == context || null == component) {
	    throw new NullPointerException();
	}
    }


    

Render the child components of this javax.faces.component.UIComponent, following the rules described for encodeBegin() to acquire the appropriate value to be rendered. This method will only be called if the rendersChildren property of this component is true.

Parameters:
context javax.faces.context.FacesContext for the response we are creating
component javax.faces.component.UIComponent whose children are to be rendered
Throws:
java.io.IOException if an input/output error occurs while rendering
java.lang.NullPointerException if context or component is null
    public void encodeChildren(FacesContext contextUIComponent component)
        throws IOException {
        if (context == null || component == null) {
            throw new NullPointerException();
        }
        if (component.getChildCount() > 0) {
        	Iterator<UIComponentkids = component.getChildren().iterator();
        	while (kids.hasNext()) {
        	    UIComponent kid = kids.next();
        	    kid.encodeAll(context);
        	}
        }
    }


    

Render the ending of the current state of the specified javax.faces.component.UIComponent, following the rules described for encodeBegin() to acquire the appropriate value to be rendered.

Parameters:
context javax.faces.context.FacesContext for the response we are creating
component javax.faces.component.UIComponent to be rendered
Throws:
java.io.IOException if an input/output error occurs while rendering
java.lang.NullPointerException if context or component is null
    public void encodeEnd(FacesContext context,
			  UIComponent component)
        throws IOException {
	if (null == context || null == component) {
	    throw new NullPointerException();
	}
    }

    

Convert the component generated client id to a form suitable for transmission to the client.

The default implementation returns the argument clientId unchanged.

Parameters:
context javax.faces.context.FacesContext for the current request
clientId the client identifier to be converted to client a specific format.
Throws:
java.lang.NullPointerException if context or clientId is null
 
    public String convertClientId(FacesContext contextString clientId) {
        if ((context == null) || (clientId == null)) {
            throw new NullPointerException();
        }
        return (clientId);
    }

    

Return a flag indicating whether this Renderer is responsible for rendering the children the component it is asked to render. The default implementation returns false.

    public boolean getRendersChildren() {
	return false;
    }


    

Attempt to convert previously stored state information into an object of the type required for this component (optionally using the registered javax.faces.convert.Converter for this component, if there is one). If conversion is successful, the new value should be returned from this method; if not, a javax.faces.convert.ConverterException should be thrown.

Parameters:
context javax.faces.context.FacesContext for the request we are processing
component javax.faces.component.UIComponent to be decoded.
submittedValue a value stored on the component during decode.
Throws:
javax.faces.convert.ConverterException if the submitted value cannot be converted successfully.
java.lang.NullPointerException if context or component is null
    public Object getConvertedValue(FacesContext context,
                                    UIComponent  component,
                                    Object       submittedValue)
        throws ConverterException {
        if ((context == null) || (component == null)) {
            throw new NullPointerException();
        }
        return submittedValue;
    }
New to GrepCode? Check out our FAQ X