Top Description Constructors Methods
jakarta.faces.view

public abstract Class ViewMetadata

extends Object
Class Inheritance
Imports
java.util.Collection, .Collections, .List, .Optional, java.util.stream.Collectors, jakarta.faces.component.UIComponent, .UIImportConstants, .UIViewAction, .UIViewParameter, .UIViewRoot, jakarta.faces.context.FacesContext

ViewMetadata is reponsible for extracting and providing view parameter metadata from VDL views. Because ViewDeclarationLanguage#getViewMetadata is required to return null for Jakarta Server Pages views and non-null for views authored in Facelets for Jakarta Faces 2, this specification only applies to Facelets for Jakarta Faces 2.

Since
2.0

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract UIViewRoot

Returns:

a UIViewRoot containing only view parameter metadata (if any)
createMetadataView
(FacesContext
the FacesContext for the current request
context
)

Creates a new UIViewRoot containing only view parameter metadata.

public static Collection<UIImportConstants>

Returns:

A Collection of UIImportConstants instances. If the view has no metadata, the collection will be empty.
getImportConstants
(UIViewRoot
The UIViewRoot from which the metadata will be extracted.
root
)

Utility method to extract view metadata from the provided UIViewRoot.

private static <C extends UIComponent> List<C>
private static Optional<UIComponent>
public static Collection<UIViewAction>

Returns:

a Collection of UIViewAction instances. If the view has no metadata, the collection will be empty.
getViewActions
(UIViewRoot
the UIViewRoot from which the metadata will be extracted.
root
)

Utility method to extract view metadata from the provided UIViewRoot.

public abstract String

Returns:

the view ID for which this ViewMetadata instance was created
getViewId
()

Get the view id

public static Collection<UIViewParameter>

Returns:

a Collection of UIViewParameter instances. If the view has no metadata, the collection will be empty.
getViewParameters
(UIViewRoot
the UIViewRoot from which the metadata will be extracted.
root
)

Utility method to extract view metadata from the provided UIViewRoot.

public static boolean

Returns:

true if the view has metadata, false otherwise.
hasMetadata
(UIViewRoot
the UIViewRoot from which the metadata will be extracted from
root
)

Utility method to determine if the the provided UIViewRoot has metadata.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ViewMetadataback to summary
public ViewMetadata()

Method Detail

createMetadataViewback to summary
public abstract UIViewRoot createMetadataView(FacesContext context)

Creates a new UIViewRoot containing only view parameter metadata. The processing of building this UIViewRoot with metadata should not cause any events to be published to the application. The implementation must call FacesContext#setProcessingEvents passing false as the argument, at the beginning of the method, and pass true to the same method at the end. The implementation must ensure that this happens regardless of ant exceptions that may be thrown.

Take note a compliant implementation has to ensure that:

  • the new UIViewRoot must be set as the FacesContext's viewRoot before applying the tag handlers, restoring the old FacesContext in a finally block.
  • The contents of the current UIViewRoot's ViewMap must be copied to the ViewMap of the new UIViewRoot before applying the tag handlers.
  • The UIImportConstants must be processed after applying the tag handlers.
Parameters
context:FacesContext

the FacesContext for the current request

Returns:UIViewRoot

a UIViewRoot containing only view parameter metadata (if any)

getImportConstantsback to summary
public static Collection<UIImportConstants> getImportConstants(UIViewRoot root)

Utility method to extract view metadata from the provided UIViewRoot.

Parameters
root:UIViewRoot

The UIViewRoot from which the metadata will be extracted.

Returns:Collection<UIImportConstants>

A Collection of UIImportConstants instances. If the view has no metadata, the collection will be empty.

getMetadataChildrenback to summary
private static <C extends UIComponent> List<C> getMetadataChildren(UIViewRoot root, Class<C> type)
Annotations
@SuppressWarnings:unchecked
getMetadataFacetback to summary
private static Optional<UIComponent> getMetadataFacet(UIViewRoot root)
getViewActionsback to summary
public static Collection<UIViewAction> getViewActions(UIViewRoot root)

Utility method to extract view metadata from the provided UIViewRoot.

Parameters
root:UIViewRoot

the UIViewRoot from which the metadata will be extracted.

Returns:Collection<UIViewAction>

a Collection of UIViewAction instances. If the view has no metadata, the collection will be empty.

getViewIdback to summary
public abstract String getViewId()

Get the view id

Returns:String

the view ID for which this ViewMetadata instance was created

getViewParametersback to summary
public static Collection<UIViewParameter> getViewParameters(UIViewRoot root)

Utility method to extract view metadata from the provided UIViewRoot.

Parameters
root:UIViewRoot

the UIViewRoot from which the metadata will be extracted.

Returns:Collection<UIViewParameter>

a Collection of UIViewParameter instances. If the view has no metadata, the collection will be empty.

hasMetadataback to summary
public static boolean hasMetadata(UIViewRoot root)

Utility method to determine if the the provided UIViewRoot has metadata. The default implementation will return true if the provided UIViewRoot has a facet named UIViewRoot#METADATA_FACET_NAME and that facet has children. It will return false otherwise.

Parameters
root:UIViewRoot

the UIViewRoot from which the metadata will be extracted from

Returns:boolean

true if the view has metadata, false otherwise.