Package jakarta.mvc
Interface Models
-
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 usingInject
and areRequestScoped
.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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Map<String,Object>
asMap()
Returns a unmodifiable view of the models map.Object
get(String name)
Retrieve a model by name.<T> T
get(String name, Class<T> clazz)
Retrieve a model by name in a type-safe way.Models
put(String name, Object model)
Stores a new model in the map.-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Method Detail
-
put
Models put(String name, Object model)
Stores a new model in the map.- Parameters:
name
- name of the modelmodel
- 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 modelclazz
- type of the model- Returns:
- The model or
null
-
-