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.
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>
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static enum | UIImportConstants.PropertyKeys
Properties that are tracked by state saving. |
| Modifier and Type | Field 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. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String | getFamily()
Implements abstract javax. 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.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.Returns name of request scope attribute under which constants will be exposed as a Map. |
| public void | |
| public void | setValueExpression(String
Name of the attribute or property for which to set a
name, ValueExpression binding)ValueExpressionOverrides javax.
Set the |
| public void |
| COMPONENT_FAMILY | back to summary |
|---|---|
| public static final String COMPONENT_FAMILY The standard component family for this component. | |
| COMPONENT_TYPE | back to summary |
|---|---|
| public static final String COMPONENT_TYPE The standard component type for this component. | |
| UIImportConstants | back to summary |
|---|---|
| public UIImportConstants()
Create a new | |
| getFamily | back to summary |
|---|---|
| public String getFamily() Implements abstract javax. Doc from javax.
Return the identifier of the component family to which this component belongs. This
identifier, in conjunction with the value of the | |
| getType | back to summary |
|---|---|
| public String getType() Returns the fully qualified name of the type to import the constant field values for.
| |
| getVar | back to summary |
|---|---|
| public String getVar() Returns name of request scope attribute under which constants will be exposed as a Map.
| |
| setType | back to summary |
|---|---|
| public void setType(final String type) Sets the fully qualified name of the type to import the constant field values for.
| |
| setValueExpression | back to summary |
|---|---|
| public void setValueExpression(String name, ValueExpression binding) Overrides javax.
Set the
| |
| setVar | back to summary |
|---|---|
| public void setVar(final String var) Sets name of request scope attribute under which constants will be exposed as a Map.
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final UIImportConstants. | |
| public static final UIImportConstants. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static UIImportConstants. | |
| public static UIImportConstants. |
| type | back to summary |
|---|---|
| public static final UIImportConstants. | |
| var | back to summary |
|---|---|
| public static final UIImportConstants. | |
| PropertyKeys | back to summary |
|---|---|
| private PropertyKeys() | |
| valueOf | back to summary |
|---|---|
| public static UIImportConstants. | |
| values | back to summary |
|---|---|
| public static UIImportConstants. | |