javax.faces.component.UIGraphic Maven / Gradle / Ivy
Show all versions of jboss-jsf-api_2.3_spec Show documentation
/*
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package javax.faces.component;
import javax.el.ValueExpression;
import javax.faces.el.ValueBinding;
/**
* UIGraphic is a {@link UIComponent} that displays
* a graphical image to the user. The user cannot manipulate this component;
* it is for display purposes only.
*
* By default, the rendererType
property must be set to
* "javax.faces.Image
". This value can be changed by calling the
* setRendererType()
method.
*/
public class UIGraphic extends UIComponentBase {
/**
* Properties that are tracked by state saving.
*/
enum PropertyKeys {
/**
* The local value of this {@link UIComponent}.
*/
value
}
// ------------------------------------------------------ Manifest Constants
/**
* The standard component type for this component.
*/
public static final String COMPONENT_TYPE = "javax.faces.Graphic";
/**
* The standard component family for this component.
*/
public static final String COMPONENT_FAMILY = "javax.faces.Graphic";
// ------------------------------------------------------------ Constructors
/**
* Create a new {@link UIGraphic} instance with default property
* values.
*/
public UIGraphic() {
super();
setRendererType("javax.faces.Image");
}
// ------------------------------------------------------ Instance Variables
//private Object value = null;
// -------------------------------------------------------------- Properties
@Override
public String getFamily() {
return (COMPONENT_FAMILY);
}
/**
* Return the image URL for this {@link UIGraphic}. This method is a
* typesafe alias for getValue()
.
*
* @return the url.
*/
public String getUrl() {
return ((String) getValue());
}
/**
* Set the image URL for this {@link UIGraphic}. This method is a
* typesafe alias for setValue()
.
*
* @param url The new image URL
*/
public void setUrl(String url) {
setValue(url);
}
/**
* Returns the value
property of the
* UIGraphic
. This will typically be rendered as an URL.
*
* @return the value.
*/
public Object getValue() {
return getStateHelper().eval(PropertyKeys.value);
}
/**
* Sets the value
property of the UIGraphic
.
* This will typically be rendered as an URL.
*
* @param value the new value
*/
public void setValue(Object value) {
getStateHelper().put(PropertyKeys.value, value);
}
// ---------------------------------------------------------------- Bindings
/**
* Return any {@link ValueBinding} set for value
if a
* {@link ValueBinding} for url
is requested; otherwise,
* perform the default superclass processing for this method.
*
* @param name Name of the attribute or property for which to retrieve
* a {@link ValueBinding}
* @return the value binding, or null
.
* @throws NullPointerException if name
* is null
*
* @deprecated This has been replaced by {@link #getValueExpression(java.lang.String)}.
*/
@Override
public ValueBinding getValueBinding(String name) {
if ("url".equals(name)) {
return (super.getValueBinding("value"));
} else {
return (super.getValueBinding(name));
}
}
/**
* Store any {@link ValueBinding} specified for url
* under value
instead; otherwise, perform the default
* superclass processing for this method. In all cases, the
* superclass is relied on to convert the ValueBinding
* to a ValueExpression
.
*
* @param name Name of the attribute or property for which to set
* a {@link ValueBinding}
* @param binding The {@link ValueBinding} to set, or null
* to remove any currently set {@link ValueBinding}
*
* @throws NullPointerException if name
* is null
*
* @deprecated This has been replaced by {@link #setValueExpression}.
*/
@Override
public void setValueBinding(String name, ValueBinding binding) {
if ("url".equals(name)) {
super.setValueBinding("value", binding);
} else {
super.setValueBinding(name, binding);
}
}
/**
* Return any {@link ValueExpression} set for value
if a
* {@link ValueExpression} for url
is requested; otherwise,
* perform the default superclass processing for this method.
*
* @param name Name of the attribute or property for which to retrieve
* a {@link ValueExpression}
* @return the value expression, or null
.
* @throws NullPointerException if name
* is null
* @since 1.2
*/
@Override
public ValueExpression getValueExpression(String name) {
if ("url".equals(name)) {
return (super.getValueExpression("value"));
} else {
return (super.getValueExpression(name));
}
}
/**
* Store any {@link ValueExpression} specified for url
under
* value
instead; otherwise, perform the default superclass
* processing for this method.
*
* @param name Name of the attribute or property for which to set
* a {@link ValueExpression}
* @param binding The {@link ValueExpression} to set, or null
* to remove any currently set {@link ValueExpression}
*
* @throws NullPointerException if name
* is null
* @since 1.2
*/
@Override
public void setValueExpression(String name, ValueExpression binding) {
if ("url".equals(name)) {
super.setValueExpression("value", binding);
} else {
super.setValueExpression(name, binding);
}
}
// ----------------------------------------------------- StateHolder Methods
}