Top Description Inners Fields Constructors Methods
javax.faces.component

public Class UIImportConstants

extends UIComponentBase
Class Inheritance
Imports
javax.el.ValueExpression, javax.faces.view.ViewMetadata

UIImportConstants imports a mapping of all constant field values of the given type in the current view.

The javax.faces.view.ViewDeclarationLanguage implementation must cause an instance of this component to be placed in the view for each occurrence of an <f:importConstants /> element placed inside of an <f:metadata /> element. The user must place <f:metadata /> as a direct child of the UIViewRoot. The ViewMetadata#createMetadataView(javax.faces.context.FacesContext) must take care of actual task of importing the constants.

Instances of this class participate in the regular JSF lifecycle, including on Ajax requests.

The purpose of this component is to provide a mapping of all constant field values of the given type in the current view. Constant field values are all public static final fields of the given type. The map key represents the constant field name as String. The map value represents the actual constant field value. This works for classes, interfaces and enums.

Usage

The below constant fields:

package com.example;

public class Foo {
    public static final String FOO1 = "foo1";
    public static final String FOO2 = "foo2";
}
package com.example;

public interface Bar {
    public static final String BAR1 = "bar1";
    public static final String BAR2 = "bar2";
}
package com.example;

public enum Baz {
    BAZ1, BAZ2;
}

Can be imported as below:

<f:metadata>
    <f:importConstants type="com.example.Foo" />
    <f:importConstants type="com.example.Bar" var="Barrr" />
    <f:importConstants type="com.example.Baz" />
</f:metadata>

And can be referenced as below:

#{Foo.FOO1}, #{Foo.FOO2}, #{Barrr.BAR1}, #{Barrr.BAR2}, #{Baz.BAZ1}, #{Baz.BAZ2}
<h:selectOneMenu value="#{bean.baz}" >
    <f:selectItems value="#{Baz}" />
</h:selectOneMenu>
Since
2.3

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum
UIImportConstants.PropertyKeys

Properties that are tracked by state saving.

Field Summary

Modifier and TypeField and Description
public static final String
COMPONENT_FAMILY

The standard component family for this component.

public static final String
COMPONENT_TYPE

The standard component type for this component.

Constructor Summary

AccessConstructor and Description
public
UIImportConstants()

Create a new UIImportConstants instance with renderer type set to null.

Method Summary

Modifier and TypeMethod and Description
public String
getFamily()

Implements abstract javax.faces.component.UIComponent.getFamily.

Return the identifier of the component family to which this component belongs.

public String

Returns:

The fully qualified name of the type to import the constant field values for.
getType
()

Returns the fully qualified name of the type to import the constant field values for.

public String

Returns:

Name of request scope attribute under which constants will be exposed as a Map.
getVar
()

Returns name of request scope attribute under which constants will be exposed as a Map.

public void
setType(final String
The fully qualified name of the type to import the constant field values for.
type
)

Sets the fully qualified name of the type to import the constant field values for.

public void
setValueExpression(String
Name of the attribute or property for which to set a ValueExpression
name
,
ValueExpression
The ValueExpression to set, or null to remove any currently set ValueExpression
binding
)

Overrides javax.faces.component.UIComponent.setValueExpression.

Set the ValueExpression used to calculate the value for the specified attribute or property name, if any.

public void
setVar(final String
Name of request scope attribute under which constants will be exposed as a Map.
var
)

Sets name of request scope attribute under which constants will be exposed as a Map.

Inherited from javax.faces.component.UIComponentBase:
addClientBehavioraddFacesListenerbroadcastclearInitialStatedecodeencodeBeginencodeChildrenencodeEndfindComponentgetAttributesgetChildCountgetChildrengetClientBehaviorsgetClientIdgetDefaultEventNamegetDescriptorMapgetEventNamesgetFacesContextgetFacesListenersgetFacetgetFacetCountgetFacetsgetFacetsAndChildrengetIdgetListenersForEventClassgetParentgetPassThroughAttributesgetRenderergetRendererTypegetRendersChildrengetValueBindinginvokeOnComponentisRenderedisTransientmarkInitialStateprocessDecodesprocessRestoreStateprocessSaveStateprocessUpdatesprocessValidatorsqueueEventremoveFacesListenerrestoreAttachedStaterestoreStatesaveAttachedStatesaveStatesetIdsetParentsetRenderedsetRendererTypesetTransientsetValueBindingsubscribeToEventunsubscribeFromEvent

Field Detail

COMPONENT_FAMILYback to summary
public static final String COMPONENT_FAMILY

The standard component family for this component.

COMPONENT_TYPEback to summary
public static final String COMPONENT_TYPE

The standard component type for this component.

Constructor Detail

UIImportConstantsback to summary
public UIImportConstants()

Create a new UIImportConstants instance with renderer type set to null.

Method Detail

getFamilyback to summary
public String getFamily()

Implements abstract javax.faces.component.UIComponent.getFamily.

Doc from javax.faces.component.UIComponent.getFamily.

Return the identifier of the component family to which this component belongs. This identifier, in conjunction with the value of the rendererType property, may be used to select the appropriate Renderer for this component instance. Note this method should NOT return null

Returns:String

the component family (not null).

Annotations
@Override
getTypeback to summary
public String getType()

Returns the fully qualified name of the type to import the constant field values for.

Returns:String

The fully qualified name of the type to import the constant field values for.

getVarback to summary
public String getVar()

Returns name of request scope attribute under which constants will be exposed as a Map.

Returns:String

Name of request scope attribute under which constants will be exposed as a Map.

setTypeback to summary
public void setType(final String type)

Sets the fully qualified name of the type to import the constant field values for.

Parameters
type:String

The fully qualified name of the type to import the constant field values for.

setValueExpressionback to summary
public void setValueExpression(String name, ValueExpression binding)

Overrides javax.faces.component.UIComponent.setValueExpression.

Set the ValueExpression used to calculate the value for the specified attribute or property name, if any. If a ValueExpression is set for the var property, throw an illegal argument exception.

Parameters
name:String

Doc from javax.faces.component.UIComponent.setValueExpression.

Name of the attribute or property for which to set a ValueExpression

binding:ValueExpression

Doc from javax.faces.component.UIComponent.setValueExpression.

The ValueExpression to set, or null to remove any currently set ValueExpression

Annotations
@Override
Exceptions
IllegalArgumentException:
If name is one of id, parent, or var.
NullPointerException:
If name is null.
setVarback to summary
public void setVar(final String var)

Sets name of request scope attribute under which constants will be exposed as a Map.

Parameters
var:String

Name of request scope attribute under which constants will be exposed as a Map.

javax.faces.component back to summary

pack-priv final Enum UIImportConstants.PropertyKeys

extends Enum<UIImportConstants.PropertyKeys>
Class Inheritance

Properties that are tracked by state saving.

Field Summary

Modifier and TypeField and Description
public static final UIImportConstants.PropertyKeys
public static final UIImportConstants.PropertyKeys

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static UIImportConstants.PropertyKeys
public static UIImportConstants.PropertyKeys[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

typeback to summary
public static final UIImportConstants.PropertyKeys type
varback to summary
public static final UIImportConstants.PropertyKeys var

Constructor Detail

PropertyKeysback to summary
private PropertyKeys()

Method Detail

valueOfback to summary
public static UIImportConstants.PropertyKeys valueOf(String name)
valuesback to summary
public static UIImportConstants.PropertyKeys[] values()