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.component.behavior;
 
 import java.util.Set;
 

ClientBehaviorBase is a convenience base class that implements the default concrete behavior of all methods defined by ClientBehavior.

Subclasses should either override getRendererType() to identify the javax.faces.render.ClientBehaviorRenderer to delegate to, or they should override getScript() to locally generate the desired Behavior script, and decode().

Since:
2.0
 
 public class ClientBehaviorBase extends BehaviorBase implements ClientBehavior {
 	
 
     private static final Logger logger = Logger.getLogger("javax.faces.component.behavior",
     "javax.faces.LogStrings");

    

Default implementation of of ClientBehavior.getScript(javax.faces.component.behavior.ClientBehaviorContext). If a javax.faces.render.ClientBehaviorRenderer is available for the specified behavior renderer type, this method delegates to the javax.faces.render.ClientBehaviorRenderer.getScript(javax.faces.component.behavior.ClientBehaviorContext,javax.faces.component.behavior.ClientBehavior) method. Otherwise, this method returns null.

Parameters:
behaviorContext the ClientBehaviorContext
Returns:
the script provided by the associated ClientBehaviorRenderer, or null if no ClientBehaviorRenderer is available.
Throws:
java.lang.NullPointerException if behaviorContext is null
Since:
2.0
 
     public String getScript(ClientBehaviorContext behaviorContext) {
 
         if (null == behaviorContext) {
             throw new NullPointerException();
         }
 
    	ClientBehaviorRenderer renderer = getRenderer(behaviorContext.getFacesContext());
        String script = null;
    	if (null != renderer){
            script = renderer.getScript(behaviorContextthis);
    	}
        return script;
    }

    

Default implementation of of ClientBehavior.decode(javax.faces.context.FacesContext,javax.faces.component.UIComponent). If a javax.faces.render.ClientBehaviorRenderer is available for the specified behavior renderer type, this method delegates to the ClientBehaviorRenderer's decode() method. Otherwise, no decoding is performed.

Parameters:
context javax.faces.context.FacesContext for the request we are processing
component javax.faces.component.UIComponent the component associated with this ClientBehavior
Throws:
java.lang.NullPointerException if context or component is null.
Since:
2.0
    public void decode(FacesContext context,
                       UIComponent component) {
    
        if (null == context || null == component) {
            throw new NullPointerException();
        }
    	ClientBehaviorRenderer renderer = getRenderer(context);
    	if (null != renderer){
            renderer.decode(contextcomponentthis);
    	}
    }
    
    

Returns the renderer type of the javax.faces.render.ClientBehaviorRenderer to use for the behavior. The default implementation returns null. Subclasses should either override this method to return a string that identifies the type of javax.faces.render.ClientBehaviorRenderer to use, or should override getScript(javax.faces.component.behavior.ClientBehaviorContext) and perform script rendering locally in the ClientBehavior implementation.

Returns:
the default renderer type, which is null.
Since:
2.0
    public String getRendererType() {
        return null;
    }
    
    

Default implementation of ClientBehavior.getHints(). By default, no hints are specified, and this method returns an empty, umodifiable set.

Returns:
an empty, unmodifiable set of ClientBehaviorHints.
Since:
2.0
    public Set<ClientBehaviorHintgetHints() {
        return Collections.emptySet();
    }

    

Convenience method to return the javax.faces.render.ClientBehaviorRenderer instance associated with this ClientBehavior, if any; otherwise, return null.

Parameters:
context javax.faces.context.FacesContext for the request we are processing
Returns:
javax.faces.render.ClientBehaviorRenderer instance from the current javax.faces.render.RenderKit or null.
Throws:
java.lang.NullPointerException if context is null.
Since:
2.0
    protected ClientBehaviorRenderer getRenderer(FacesContext context) {
    	if (null == context){
            throw new NullPointerException();
    	}
    	ClientBehaviorRenderer renderer = null;
        String rendererType = getRendererType();
        if (null != rendererType){
            RenderKit renderKit = context.getRenderKit();
            if (null != renderKit){
                renderer = renderKit.getClientBehaviorRenderer(rendererType);
            }
            if (null == renderer){
                if (.isLoggable(.)){
                    .fine("Can't get  behavior renderer for type " + rendererType);
                }				
            }
        } else {
            if(.isLoggable(.)){
                .fine("No renderer-type for behavior " + this.getClass().getName());
            }
        }
        return renderer;
    }
New to GrepCode? Check out our FAQ X