Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * $Id: UIComponentELTag.java,v 1.7 2007/01/29 07:29:00 rlubke Exp $
   */
  
  /*
   * The contents of this file are subject to the terms
   * of the Common Development and Distribution License
   * (the License). You may not use this file except in
   * compliance with the License.
  * 
  * You can obtain a copy of the License at
  * https://javaserverfaces.dev.java.net/CDDL.html or
  * legal/CDDLv1.0.txt. 
  * See the License for the specific language governing
  * permission and limitations under the License.
  * 
  * When distributing Covered Code, include this CDDL
  * Header Notice in each file and include the License file
  * at legal/CDDLv1.0.txt.    
  * If applicable, add the following below the CDDL Header,
  * with the fields enclosed by brackets [] replaced by
  * your own identifying information:
  * "Portions Copyrighted [year] [name of copyright owner]"
  * 
  * [Name of File] [ver.__] [Date]
  * 
  * Copyright 2005 Sun Microsystems Inc. All Rights Reserved
  */
 
 package javax.faces.webapp;
 
 

UIComponentELTag specializes its superclass to allow for properties that take their values from EL API expressions.

This tag is designed for use with Faces version 1.2 and JSP version 2.1 containers.

 
 
 public abstract class UIComponentELTag extends UIComponentClassicTagBase implements Tag {
 
 
     // ------------------------------------------------------------- Attributes
 

    

The value binding expression (if any) used to wire up this component to a javax.faces.component.UIComponent property of a JavaBean class.

 
     private ValueExpression binding = null;


    

Set the value expression for our component.

Parameters:
binding The new value expression
Throws:
javax.servlet.jsp.JspException if an error occurs
 
     public void setBinding(ValueExpression bindingthrows JspException {
 	this. = binding;
     }
 
     protected boolean hasBinding() {
 	return null != ;
     }

    

An override for the rendered attribute associated with our javax.faces.component.UIComponent.

 
     private ValueExpression rendered = null;


    

Set an override for the rendered attribute.

Parameters:
rendered The new value for rendered attribute
 
     public void setRendered(ValueExpression rendered) {
         this. = rendered;
     }

    

Return the javax.el.ELContext for the javax.faces.context.FacesContext for this request.

This is a convenience for getFacesContext().getELContext().

    protected ELContext getELContext() {
	ELContext result = null;
	if (null != fc) {
	    result = fc.getELContext();
	}
	return result;
    }
    // ------------------------------------------------------------ Tag Methods



    

Release any resources allocated during the execution of this tag handler.

    public void release() {
	this. = null;
        this. = null;
	super.release();
    }
    // ------------------------------------------------------- Protected Methods

    

Override properties and attributes of the specified component, if the corresponding properties of this tag handler instance were explicitly set. This method must be called ONLY if the specified javax.faces.component.UIComponent was in fact created during the execution of this tag handler instance, and this call will occur BEFORE the javax.faces.component.UIComponent is added to the view.

Tag subclasses that want to support additional set properties must ensure that the base class setProperties() method is still called. A typical implementation that supports extra properties foo and bar would look something like this:

 protected void setProperties(UIComponent component) {
   super.setProperties(component);
   if (foo != null) {
     component.setAttribute("foo", foo);
   }
   if (bar != null) {
     component.setAttribute("bar", bar);
   }
 }
 

The default implementation overrides the following properties:

  • rendered - Set if a value for the rendered property is specified for this tag handler instance.
  • rendererType - Set if the getRendererType() method returns a non-null value.

Parameters:
component javax.faces.component.UIComponent whose properties are to be overridden
    protected void setProperties(UIComponent component) {
        // The "id" property is explicitly set when components are created
        // so it does not need to be set here
        if ( != null) {
            if (.isLiteralText()) {
                try {
                    component.setRendered(Boolean.valueOf(.getExpressionString())
                            .booleanValue());
                } catch (ELException e) {
                    throw new FacesException(e);
                }
            } else {
                component.setValueExpression("rendered");
            }
        }
        if (getRendererType() != null) {
            component.setRendererType(getRendererType());
        }
    }


    

Create and return a new child component of the type returned by calling getComponentType(). If this UIComponentELTag has a non-null binding attribute, this is done by call javax.faces.application.Application.createComponent(java.lang.String) with the javax.el.ValueExpression created for the binding attribute, and the javax.el.ValueExpression will be stored on the component. Otherwise, javax.faces.application.Application.createComponent(java.lang.String) is called with only the component type. Finally, initialize the components id and other properties.

Parameters:
context javax.faces.context.FacesContext for the current request
newId id of the component
    protected UIComponent createComponent(FacesContext contextString newIdthrows JspException {
        UIComponent component;
        Application application = context.getApplication();
        if ( != null) {
            component = application.createComponent(context,
                                                    getComponentType());
	    component.setValueExpression("binding");
        } else {
            component = application.createComponent(getComponentType());
        }
        component.setId(newId);
        setProperties(component);
        return component;
    }
New to GrepCode? Check out our FAQ X