public class ExpressionCustomizer
extends java.lang.Object
ExpressionResolver.
The customization is only scoped to the current request, not a global one. The resource type implementation needs to use this class explicitly to make the customization available in the request scope going forward.
For example, the resource type implementation of CQ Dialog (/apps/my/dialog) wants to register
cqDesign variable so that it can be used in EL expression:
Design design = getDesign();
ExpressionCustomizer customizer = ExpressionCustomizer.from(request);
customizer.setVariable("cqDesign", design);
Then in the content structure, the content author can use cqDesign variable in the property that accepts
EL:
+ /apps/content/my/dialog
- sling:resourceType = "my/dialog"
+ field1
- sling:resourceType = "my/textfield"
- value = "${cqDesign.id}"
| Constructor and Description |
|---|
ExpressionCustomizer() |
| Modifier and Type | Method and Description |
|---|---|
static ExpressionCustomizer |
from(javax.servlet.ServletRequest request)
Returns the instance from the given request.
|
java.lang.Object |
getVariable(java.lang.String name)
Returns the value of the variable with the given name.
|
boolean |
hasVariable(java.lang.String name)
Returns
true if there is a variable with the given name; false otherwise. |
void |
setVariable(java.lang.String name,
java.lang.Object value)
Creates a variable with the given name and value.
|
@Nonnull public static ExpressionCustomizer from(@Nonnull javax.servlet.ServletRequest request)
request - the current request acting as the scope of the customization@CheckForNull
public java.lang.Object getVariable(@Nonnull
java.lang.String name)
name - the name of the variablenull if there is no variable with that namepublic void setVariable(@Nonnull
java.lang.String name,
@Nonnull
java.lang.Object value)
Setting an existing variable with the same name will overwrite its value.
name - the name of the variablevalue - the value of the variablepublic boolean hasVariable(@Nonnull
java.lang.String name)
true if there is a variable with the given name; false otherwise.name - the name of the variabletrue if there is a variable with the given name; false otherwiseCopyright © 2010 - 2023 Adobe. All Rights Reserved