Class ViewIdBean

  • All Implemented Interfaces:
    Serializable

    @ViewScoped
    @Named
    public class ViewIdBean
    extends Object
    implements Serializable
    Bean that associates a UUID with each view. This is better that relying on the internal java.faces.ViewState, which may not contain an ID in case of client-side state saving etc.
    Since:
    7.0.0
    Author:
    XIMA MEDIA GmbH
    See Also:
    Serialized Form
    • Constructor Detail

      • ViewIdBean

        public ViewIdBean()
    • Method Detail

      • getViewId

        public UUID getViewId()
        Returns:
        The ID of the current view.
      • getCurrentViewId

        public static Optional<UUID> getCurrentViewId()
        Returns:
        The ID of the current view, if this method is called within a JSF context. Otherwise,returns an empty optional.
      • isSameView

        public static boolean isSameView​(UUID viewId)
        Parameters:
        viewId - A view ID against which to check.
        Returns:
        true when called within a JSF context and the current view equals the given view ID, false otherwise.
      • isDifferentView

        public static boolean isDifferentView​(UUID viewId)
        Parameters:
        viewId - A view ID against which to check.
        Returns:
        When the given view ID is not null: true when either not within a JSF context or the current view is different from the given view ID, false otherwise. When the given view ID is null: true when there is a an active view ID, false otherwise.