Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * 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
  * 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.webapp;

UIComponentTag is the base class for all JSP custom actions that correspond to user interface components in a page that is rendered by JavaServer Faces.

In this version of the specification, UIComponentTag extends UIComponentClassicTagBase to add properties that use the Faces 1.1 Expression Language.

Use of this class has been replaced with UIComponentELTag, which extends UIComponentClassicTagBase to add properties that use the EL API introduced as part of JSP 2.1.
 public abstract class UIComponentTag extends UIComponentClassicTagBase implements Tag {
     // ------------------------------------------------------------- Properties

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

     private String binding = null;


Set the value binding expression for our component.

binding The new value binding expression
java.lang.IllegalArgumentException if the specified binding is not a valid value binding expression.
     public void setBinding(String bindingthrows JspException {
 	if (!isValueReference(binding)) {
 	    throw new IllegalArgumentException();
 	this. = binding;
     protected boolean hasBinding() {
 	return null != ;


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

    private String rendered = null;


Set an override for the rendered attribute.

rendered The new value for rendered attribute
    public void setRendered(String rendered) {
        this. = rendered;


Flag indicating whether or not rendering should occur.

    private boolean suppressed = false;
    protected boolean isSuppressed() {
        return ();


Return true if the specified value conforms to the syntax requirements of a value binding expression. Such expressions ` * may be used on most component tag attributes to signal a desire for deferred evaluation of the attribute or property value to be set on the underlying javax.faces.component.UIComponent.

value The value to evaluate
java.lang.NullPointerException if value is null
    public static boolean isValueReference(String value) {
	if (value == null) {
	    throw new NullPointerException();
	int start = value.indexOf("#{");
	if ((start != -1) && (start < value.indexOf('}'start))) {
            return true;
        return false;
    // ------------------------------------------ Methods from Tag


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

    public void release() {
	this. = false;
	this. = null;
        this. = null;
    // ----------------  Concrete Implementations of methods from superclass


    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 (isValueReference()) {
	    } else {
	if (getRendererType() != null) {


Implement createComponent using Faces 1.1 EL API.

    protected UIComponent createComponent(FacesContext contextString newId) {
        UIComponent component;
        Application application = context.getApplication();
        if ( != null) {
            ValueBinding vb = application.createValueBinding();
            component = application.createComponent(vbcontext,
        } else {
            component = application.createComponent(getComponentType());
        return component;
    // Tag tree navigation


Locate and return the nearest enclosing UIComponentTag if any; otherwise, return null.

context PageContext for the current page
    public static UIComponentTag getParentUIComponentTag(PageContext context) {
        UIComponentClassicTagBase result =
        if (!(result instanceof UIComponentTag)) {
            return new UIComponentTagAdapter(result);
        return ((UIComponentTagresult);
    // --------------------------------------------------------- Private Classes

This adatper exposes a UIComponentClassicTagBase as a UIComponentTag for 1.1 component libraries that rely on UIComponent.getParentUIComponentTag(). This will work for most use cases, but there are probably some edge cases out there that we're not aware of.
    private static class UIComponentTagAdapter extends UIComponentTag {
        public UIComponentTagAdapter(UIComponentClassicTagBase classicDelegate) {
            this. = classicDelegate;
        public String getComponentType() {
            return .getComponentType();
        public String getRendererType() {
            return .getRendererType();
        public int doStartTag() throws JspException {
            throw new IllegalStateException();
        public int doEndTag() throws JspException {
            throw new IllegalStateException();
        public UIComponent getComponentInstance() {
            return .getComponentInstance();
        public boolean getCreated() {
            return .getCreated();
        public Tag getParent() {
            return .getParent();
        public void setParent(Tag parent) {
            throw new IllegalStateException();
New to GrepCode? Check out our FAQ X