Class Facelets


  • @Typed
    public final class Facelets
    extends Object

    Collection of utility methods for Facelets code.

    Since:
    2.0
    Author:
    Arjan Tijms
    • Method Detail

      • getString

        public static String getString​(FaceletContext context,
                                       TagAttribute tagAttribute)
        Returns the String value of the given tag attribute.
        Parameters:
        context - The involved Facelet context.
        tagAttribute - The tag attribute to retrieve the value from.
        Returns:
        The String value of the given tag attribute, or null if the tag attribute is null.
      • getStringLiteral

        public static String getStringLiteral​(TagAttribute tagAttribute,
                                              String name)
        Returns the String literal of the given tag attribute.
        Parameters:
        tagAttribute - The tag attribute to retrieve the value from.
        name - The tag attribute name; this is only used in exception message.
        Returns:
        The String literal of the given tag attribute, or null if the tag attribute is null.
        Throws:
        IllegalArgumentException - When the attribute is not a literal.
        Since:
        2.6
      • getBoolean

        public static boolean getBoolean​(FaceletContext context,
                                         TagAttribute tagAttribute)
        Returns the boolean value of the given tag attribute.
        Parameters:
        context - The involved Facelet context.
        tagAttribute - The tag attribute to retrieve the value from.
        Returns:
        The boolean value of the given tag attribute, or false if the tag attribute is null.
      • getObject

        public static Object getObject​(FaceletContext context,
                                       TagAttribute tagAttribute)
        Returns the Object value of the given tag attribute
        Parameters:
        context - The involved Facelet context.
        tagAttribute - The tag attribute to retrieve the value from.
        Returns:
        The Object value of the given tag attribute, or null if the tag attribute is null.
      • getObject

        public static <T> T getObject​(FaceletContext context,
                                      TagAttribute tagAttribute,
                                      Class<?> type)
        Returns the typed Object value of the given tag attribute
        Type Parameters:
        T - The expected return type.
        Parameters:
        context - The involved Facelet context.
        tagAttribute - The tag attribute to retrieve the value from.
        type - The expected type of the Object value.
        Returns:
        The typed Object value of the given tag attribute, or null if the tag attribute is null.
        Throws:
        ClassCastException - When T is of wrong type.
      • getValueExpression

        public static ValueExpression getValueExpression​(FaceletContext context,
                                                         TagAttribute tagAttribute,
                                                         Class<?> type)
        Returns the value of the given tag attribute as a value expression, so it can be carried around and evaluated at a later moment in the lifecycle without needing the Facelet context.
        Parameters:
        context - The involved Facelet context.
        tagAttribute - The tag attribute to extract the value expression from.
        type - The expected type of the value behind the value expression.
        Returns:
        The value of the given tag attribute as a value expression, or null if the tag attribute is null.