Top Description Fields Constructors Methods
com.sun.faces.util

public Class ScopedRunner

extends Object
Class Inheritance
Imports
java.util.HashMap, .Map, jakarta.faces.context.FacesContext

This class helps in letting code run within its own scope. Such scope is defined by specific variables being available to EL within it. The request scope is used to store the variables.
Author
Arjan Tijms

Field Summary

Modifier and TypeField and Description
private final FacesContext
private final Map<String, Object>
private final Map<String, Object>

Constructor Summary

AccessConstructor and Description
public
public
ScopedRunner(FacesContext context, Map<String, Object> scopedVariables)

Method Summary

Modifier and TypeMethod and Description
public void
invoke(Runnable
The callback.
callback
)

Invokes the callback within the scope of the variables being given in the constructor.

private void
private void
public ScopedRunner

Returns:

this ScopedRunner, so adding variables and finally calling invoke can be chained.
with
(String
the key name of the variable
key
,
Object
the value of the variable
value
)

Adds the given variable to this instance.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextback to summary
private final FacesContext context
previousVariablesback to summary
private final Map<String, Object> previousVariables
scopedVariablesback to summary
private final Map<String, Object> scopedVariables

Constructor Detail

ScopedRunnerback to summary
public ScopedRunner(FacesContext context)
ScopedRunnerback to summary
public ScopedRunner(FacesContext context, Map<String, Object> scopedVariables)

Method Detail

invokeback to summary
public void invoke(Runnable callback)

Invokes the callback within the scope of the variables being given in the constructor.

Parameters
callback:Runnable

The callback.

restorePreviousScopeback to summary
private void restorePreviousScope()
setNewScopeback to summary
private void setNewScope()
withback to summary
public ScopedRunner with(String key, Object value)

Adds the given variable to this instance. Can be used in a builder-pattern.

Parameters
key:String

the key name of the variable

value:Object

the value of the variable

Returns:ScopedRunner

this ScopedRunner, so adding variables and finally calling invoke can be chained.