Expand my Community achievements bar.

Introducing Adobe LLM Optimizer: Own your brand’s presence in AI-Powered search and discovery
SOLVED

What all the object available ootb in granite rendercondition dialog

Avatar

Level 2

Hi All,

What all the ootb objects available in granite rendercondition.

I have browsed and few of the blog mentioned requestPathinfo is available so like this What other ootb objects available in granite rendercondition to use in component dialog.

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
5 Replies

Avatar

Level 9

hi @AmitSi18,

The granite render condition is marked with "@Model," indicating that it is a Sling Model. You can utilise all the available injectors and the out-of-the-box (OOTB) global objects as outlined in the documentation. Here are some examples demonstrating how different Java objects are injected into the implementation:

https://ankanghosh-webdev.medium.com/granite-render-condition-in-aem-64d32f03a7d1

https://jpsoares.medium.com/aem-granite-render-conditions-438c804b1e5a

 

Avatar

Level 4

Hi @AmitSi18 ,

Like you are using requestPathInfo there are many ootb objects in aem which you can access In AEM. You can access all the objects which are injected in a sling model. So there are many objects like SlingHttpServletRequest, Resource, ValueMap, ResourceResolver, Session, and Authorizable for user and request context. You can also access RequestPathInfo for URL details, WCMMode for authoring modes, and Page, PageManager for page-related context. Additionally, Component, ComponentContext, and Bindings are available to control field visibility dynamically based on user roles, request parameters, and authoring mode.

Avatar

Community Advisor

Hi @AmitSi18 ,

 

In Granite RenderCondition (used in AEM dialogs to conditionally show/hide fields), the underlying implementation uses Sling Models, meaning you have access to all Sling injectable objects that apply in the context of a dialog rendering request.

Complete list of OOTB objects that you can inject into a Granite RenderCondition class using Sling Models:

Avatar

Level 2

@giuseppebag @ShivamKumar @AmitVishwakarma 

I am just trying to understand this.

I have not written and custom servlet or sling model for requestPathInfo but I am still able to use it in rendercondition expression(refer below code). But other object are not available like resource, request etc... mentioned by @AmitVishwakarma 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="nt:unstructured"
jcr:title="Properties"
sling:resourceType="cq/gui/components/authoring/dialog" xmlns:granite="http://www.adobe.com/jcr/granite/1.0">
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/fixedcolumns">
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<text
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldLabel="Text"
name="./text"/>
<myTextField
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldDescription="This is a conditional text show hide text field"
fieldLabel="My Text Field"
name="./myTextField">
<granite:rendercondition
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/renderconditions/simple"
expression="${granite:containsIgnoreCase(requestPathInfo.suffix, '/en/home-page')}"/>
</myTextField>>
</items>
</column>
</items>
</content>
</jcr:root>

@Model(adaptables = Resource.class)
public class HelloWorldModel {

@ValueMapValue(name=PROPERTY_RESOURCE_TYPE, injectionStrategy=InjectionStrategy.OPTIONAL)
@Default(values="No resourceType")
protected String resourceType;

@SlingObject
private Resource currentResource;

@SlingObject
private ResourceResolver resourceResolver;

private String message;

@ValueMapValue(injectionStrategy=InjectionStrategy.OPTIONAL)
private String text;

@PostConstruct
protected void init() {
PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
String currentPagePath = Optional.ofNullable(pageManager)
.map(pm -> pm.getContainingPage(currentResource))
.map(Page::getPath).orElse("");

message = "Hello World!\n"
+ "Resource type is: " + resourceType + "\n"
+ "Current page is: " + currentPagePath + "\n";
}

public String getMessage() {
return message;
}
}

Avatar

Correct answer by
Community Advisor

Hi @AmitSi18 

You can check supported EL functions and variable here

https://developer.adobe.com/experience-manager/reference-materials/6-5/granite-ui/api/jcr_root/libs/... 

Arun Patidar

AEM LinksLinkedIn