Hiding Granite UI Resource Dynamically

Granite UI offers two ways of hiding the resource dynamically.
  • FilteringResourceWrapper (granite:hide)
  • RenderCondition (granite:rendercondition)
UseCase: To hide/filter a resource from being rendered based on some custom conditions.
Understanding the differences in terms of usage:

granite:hide
granite:rendercondition
Decision making logic/condition is defined using Expression Language(EL).

Decision making logic/condition is defined in a component ie. Separate rendercondition component will hold the logic.
Supported Variables/functions in EL (for Granite UI resource) are available here OOB rendercondition components are available here
Custom variable can also be registered using ExpressionCustomizer. One such variable is cqDesign for fetching the design properties as we would do with currrentDesign global object.
(OOB core components uses this variable in EL- ${cqDesign.customproperty})
Custom rendercondition component can be created based on our requirement.
Usage: Property named "granite:hide" is to be created with value being EL on the resource to be filtered Node named "granite:rendercondition" or "rendercondition" is to be created under the resource to be filtered.
Properties for this node being "sling:resourceType" with the value as rendercondition component or custom component's path
Ex: Widely used in OOB core components to control dialog fields based on design/policy configuration of that component.
Condition can be controlled at property level itself making use of cqDesign custom variable. Hence EL is preferred in this case.
Ex: In Page selection -> action bar -> Create -> Workflow option will be available/should be rendered for those who have access to /etc/workflow/models.
This condition has to be implemented making use of AccessControlManager API on specific path. Hence rendercondition is preferred for this use case.

Specific example on each of this is to be covered in a separate post for better clarity.

Reference: Adobe helpx links on Granite UI

Comments

  1. When planning for a new kitchen, it’s a smart move to choose your worktops and then build from there.
    Astrum Granite houses a broad selection of Kitchen Worktops, Quartz Countertops & Kitchen Countertops. We offer vast range of Granite Worktops, Quartz Countertops, Marble Kitchen Worktops

    The large selection of options can be daunting, so if you need any assistance or advice, our team have years of experience and the knowledge to steer you in the right direction, so don't be afraid to give us a call to get Online Quote.

    ReplyDelete

Post a Comment

Popular posts from this blog

Embedding Third party dependency/OSGi bundle in AEM application hosted in AEMasCS

OSGI Factory Configuration implementation

Creation of Template Types for Editable templates