All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.faces.component.UIParameter Maven / Gradle / Ivy

Go to download

This is the master POM file for Oracle's Implementation of the JSF 2.1 Specification.

There is a newer version: 2.1
Show newest version
/*
 * $Id: UIParameter.java,v 1.29 2006/06/05 21:14:25 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.component;


import javax.el.ELException;
import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.context.FacesContext;



/**
 * 

UIParameter is a {@link UIComponent} that represents * an optionally named configuration parameter for a parent component.

* *

Parent components should retrieve the value of a parameter by calling * getValue(). In this way, the parameter value can be set * directly on the component (via setValue()), or retrieved * indirectly via the value binding expression.

* *

In some scenarios, it is necessary to provide a parameter name, in * addition to the parameter value that is accessible via the * getValue() method. * {@link javax.faces.render.Renderer}s that support parameter names on their * nested {@link UIParameter} child components should document * their use of this property.

*/ public class UIParameter extends UIComponentBase { // ------------------------------------------------------ Manifest Constants /** *

The standard component type for this component.

*/ public static final String COMPONENT_TYPE = "javax.faces.Parameter"; /** *

The standard component family for this component.

*/ public static final String COMPONENT_FAMILY = "javax.faces.Parameter"; // ------------------------------------------------------------ Constructors /** *

Create a new {@link UIParameter} instance with default property * values.

*/ public UIParameter() { super(); setRendererType(null); } // ------------------------------------------------------ Instance Variables private String name = null; private Object value = null; // -------------------------------------------------------------- Properties public String getFamily() { return (COMPONENT_FAMILY); } /** *

Return the optional parameter name for this parameter.

*/ public String getName() { if (this.name != null) { return (this.name); } ValueExpression ve = getValueExpression("name"); if (ve != null) { try { return ((String) ve.getValue(getFacesContext().getELContext())); } catch (ELException e) { throw new FacesException(e); } } else { return (null); } } /** *

Set the optional parameter name for this parameter.

* * @param name The new parameter name, * or null for no name */ public void setName(String name) { this.name = name; } /** *

Returns the value property of the * UIParameter.

*/ public Object getValue() { if (this.value != null) { return (this.value); } ValueExpression ve = getValueExpression("value"); if (ve != null) { try { return (ve.getValue(getFacesContext().getELContext())); } catch (ELException e) { throw new FacesException(e); } } else { return (null); } } /** *

Sets the value property of the\ * UIParameter.

* * @param value the new value */ public void setValue(Object value) { this.value = value; } // ----------------------------------------------------- StateHolder Methods private Object[] values; public Object saveState(FacesContext context) { if (values == null) { values = new Object[3]; } values[0] = super.saveState(context); values[1] = name; values[2] = value; return (values); } public void restoreState(FacesContext context, Object state) { values = (Object[]) state; super.restoreState(context, values[0]); name = (String) values[1]; value = values[2]; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy