Hi everyone, We're planning to disable a field for a certain component if it is a child of a particular parent component.
I can't see any particular sample codes for it.
I've been looking for some items (like granite rendercondition) but there isn't much sample for that on how to use it or if it really suits the need on our problem. Thanks!
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @LyonMartin,
One option would be to use java code. You can create a java class to fetch parent component and do the comparison.
In the component field, it can be added as mentioned below.
<granite:rendercondition
jcr:primaryType="nt:unstructured"
sling:resourceType="mysite/renderconditions/customcomparisoncomponent"/>
Please refer below URL for more details.
https://jpsoares.medium.com/aem-granite-render-conditions-438c804b1e5a
hope it helps!
Regards,
Rohit
Hi @LyonMartin,
One option would be to use java code. You can create a java class to fetch parent component and do the comparison.
In the component field, it can be added as mentioned below.
<granite:rendercondition
jcr:primaryType="nt:unstructured"
sling:resourceType="mysite/renderconditions/customcomparisoncomponent"/>
Please refer below URL for more details.
https://jpsoares.medium.com/aem-granite-render-conditions-438c804b1e5a
hope it helps!
Regards,
Rohit
Hi @LyonMartin ,
This is a scenario that I think would require extraClientlibs
https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/could-you-please-explain-w...
Along with some custom script in your component.
Component JS :
- Based on the parent component, the child component can have a class if the condition is met.
Dialog JS:
You would need to hide/disable the field based on your conditions through a custom script.( JS )
You can look for the class present, and then if it is , you can disable/hide.
@LyonMartin
- You can use garnite:rendercondition here. By writing you logic in Sling Modal and check for the child of a parent component and then send the true value in blue snippet once you condition is fulfilled to show the field.
Set checkValue to true based on the logic to show the field and pass it to RenderCondition as below:
boolean checkValue = false;
request.setAttribute(RenderCondition.class.getName(),
new SimpleRenderCondition(true));
Views
Likes
Replies