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;
 
 

ClientBehaviorContext provides context information that may be useful to ClientBehavior.getScript(javax.faces.component.behavior.ClientBehaviorContext) implementations.

Since:
2.0
 
 public abstract class ClientBehaviorContext {

    

Creates a ClientBehaviorContext instance.

Parameters:
context the FacesContext for the current request.
component the component instance to which the ClientBehavior is attached.
eventName the name of the behavior event to which the ClientBehavior is attached.
sourceId the id to use as the ClientBehavior's "source".
parameters the collection of parameters for submitting ClientBehaviors to include in the request.
Returns:
a ClientBehaviorContext instance configured with the provided values.
Throws:
java.lang.NullPointerException if context, component or eventName is null
Since:
2.0
 
                                                         UIComponent component,
                                                         String eventName,
                                                         String sourceId,
                                                         Collection<ClientBehaviorContext.Parameterparameters) {
 
         return new ClientBehaviorContextImpl(contextcomponenteventNamesourceIdparameters);
     }

    

Returns the javax.faces.context.FacesContext for the current request.

Since:
2.0
 
     abstract public FacesContext getFacesContext();

    

Returns the javax.faces.component.UIComponent that is requesting the ClientBehavior script.

Since:
2.0
    abstract public UIComponent getComponent();

    

Returns the name of the behavior event for which the ClientBehavior script is being requested.

Since:
2.0
    abstract public String getEventName();

    

Returns an id for use as the ClientBehavior source. ClientBehavior implementations that submit back to the Faces lifecycle are required to identify which component triggered the ClientBehavior-initiated request via the javax.faces.source request parameter. In most cases, th source id can be trivially derived from the element to which the behavior's client-side script is attached - ie. the source id is typically the id of this element. However, in components which produce more complex content, the behavior script may not be able to determine the correct id to use for the javax.faces.source value. The getSourceId() method allows the component to pass this information into the ClientBehavior.getScript(javax.faces.component.behavior.ClientBehaviorContext) implementation.

Returns:
the id for the behavior's script to use as the "source", or null if the Behavior's script can identify the source from the DOM.
Since:
2.0
    abstract public String getSourceId();

    

Returns parameters that "submitting" ClientBehavior implementations should include when posting back data into the Faces lifecycle. If no parameters are specified, this method returns an empty (non-null) collection.

Since:
2.0
    // Little static member class that provides a default implementation
    private static final class ClientBehaviorContextImpl extends ClientBehaviorContext {
        private FacesContext context;
        private UIComponent component;
        private String eventName;
        private String sourceId;
        private ClientBehaviorContextImpl(FacesContext context,
                                    UIComponent component,
                                    String eventName,
                                    String sourceId,
                                    Collection<ClientBehaviorContext.Parameterparameters) {
            if (null == context) {
                throw new NullPointerException();
            }
            if (null == component) {
                throw new NullPointerException();
            }
            if (null == eventName) {
                throw new NullPointerException();
            }
            this. = context;
            this. = component;
            this. = eventName;
            this. = sourceId;
            this. =  (parameters == null) ? 
                                   Collections.<ClientBehaviorContext.Parameter>emptyList() : 
                                   parameters;
        }        
        @Override
        public FacesContext getFacesContext() {
            return ;
        }
        @Override
        public UIComponent getComponent() {
            return ;
        }
        @Override
        public String getEventName() {
            return ;
        }
        @Override
        public String getSourceId() {
            return ;
        }
        @Override
            return ;
        }
    }

    

Parameter instances represent name/value pairs that "submitting" ClientBehavior implementations should include when posting back into the Faces lifecycle. ClientBehavior implementations can determine which Parameters to include by calling ClientBehaviorContext.getParameters().

Since:
2.0
    public static class Parameter {
        private String name;
        private Object value;

        

Creates a Parameter instance.

Parameters:
name the name of the parameter
value the value of the parameter
Throws:
java.lang.NullPointerException if name is null.
Since:
2.0
        public Parameter(String nameObject value) {
            if (null == name) {
                throw new NullPointerException();
            }
            this. = name;
            this. = value;
        }

        

Returns the Parameter's name.

Since:
2.0
        public String getName() {
            return ;
        }

        

Returns the Parameter's value.

Since:
2.0
        public Object getValue() {
            return ;
        }
    }
New to GrepCode? Check out our FAQ X