Package jakarta.mvc

Interface Models

  • All Superinterfaces:
    Iterable<String>

    public interface Models
    extends Iterable<String>

    A map of name to model instances used by a ViewEngine to process a view. Instances implementing this interface must be injectable using Inject and are RequestScoped.

    Note that certain view engines, such as engines for Jakarta Server Pages and Facelets, support model binding via Named in which case the use of Models is optional.

    Since:
    1.0
    Author:
    Santiago Pericas-Geertsen, Christian Kaltepoth, Ivar Grimstad
    See Also:
    Named, RequestScoped
    • Method Detail

      • put

        Models put​(String name,
                   Object model)
        Stores a new model in the map.
        Parameters:
        name - name of the model
        model - model to store in the map
        Returns:
        the current instance to allow method chaining
      • get

        Object get​(String name)
        Retrieve a model by name.
        Parameters:
        name - name of the model
        Returns:
        the model or null
      • get

        <T> T get​(String name,
                  Class<T> clazz)
        Retrieve a model by name in a type-safe way.
        Type Parameters:
        T - type of the model
        Parameters:
        name - name of the model
        clazz - type of the model
        Returns:
        The model or null
      • asMap

        Map<String,​Object> asMap()
        Returns a unmodifiable view of the models map.
        Returns:
        unmodifiable map