Top Description Methods
jakarta.mvc

public Interface Models

extends Iterable<String>
Imports
java.util.Map

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

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

Authors
Santiago Pericas-Geertsen, Christian Kaltepoth, Ivar Grimstad
Since
1.0
See Also
jakarta.inject.Named, jakarta.enterprise.context.RequestScoped

Method Summary

Modifier and TypeMethod and Description
public Map<String, Object>

Returns:

unmodifiable map
asMap
()

Returns a unmodifiable view of the models map.

public Object

Returns:

the model or null
get
(String
name of the model
name
)

Retrieve a model by name.

public <
type of the model
T
>
T

Returns:

The model or null
get
(String
name of the model
name
,
Class<T>
type of the model
clazz
)

Retrieve a model by name in a type-safe way.

public Models

Returns:

the current instance to allow method chaining
put
(String
name of the model
name
,
Object
model to store in the map
model
)

Stores a new model in the map.

Inherited from java.lang.Iterable:
forEachiteratorspliterator

Method Detail

asMapback to summary
public Map<String, Object> asMap()

Returns a unmodifiable view of the models map.

Returns:Map<String, Object>

unmodifiable map

getback to summary
public Object get(String name)

Retrieve a model by name.

Parameters
name:String

name of the model

Returns:Object

the model or null

getback to summary
public <T> T get(String name, Class<T> clazz)

Retrieve a model by name in a type-safe way.

Parameters
<T>
type of the model
name:String

name of the model

clazz:Class<T>

type of the model

Returns:T

The model or null

putback to summary
public Models put(String name, Object model)

Stores a new model in the map.

Parameters
name:String

name of the model

model:Object

model to store in the map

Returns:Models

the current instance to allow method chaining