Expand my Community achievements bar.

SOLVED

resourceType vs resourceSuperType: when to use?

Avatar

Level 9
  • if I create a new HTL component or page template and I'm extending another custom component, I would normally use sling:resourceType
  • And if I'm extending a core component, I would use sling:resourceSuperType.

 

But I never really found out why? I tried searching the net but I didn't find the answer.

 

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 9

hi @jayv25585659 ,

 

sling:resourceSuperType: It is used to achieve inheritance in cq. When set, it inherits the specified component to this component. The resource type is meant to point to rendering/processing scripts, editing dialogs, etc.

 

sling:resourceType: It is a path, which locates the script to be used for rendering the content. Path used can be absolute or relative. 

 

This sling:resourceSuperType properties are also considered when trying to find a script. The advantage of resource super types is that they may form a hierarchy of resources where the default resource type sling/servlet/default (used by the default servlets) is effectively the root.

Refer https://sling.apache.org/documentation/the-sling-engine/resources.html

https://experienceleague.adobe.com/en/docs/experience-manager-65/content/implementing/developing/int...

View solution in original post

3 Replies

Avatar

Correct answer by
Level 9

hi @jayv25585659 ,

 

sling:resourceSuperType: It is used to achieve inheritance in cq. When set, it inherits the specified component to this component. The resource type is meant to point to rendering/processing scripts, editing dialogs, etc.

 

sling:resourceType: It is a path, which locates the script to be used for rendering the content. Path used can be absolute or relative. 

 

This sling:resourceSuperType properties are also considered when trying to find a script. The advantage of resource super types is that they may form a hierarchy of resources where the default resource type sling/servlet/default (used by the default servlets) is effectively the root.

Refer https://sling.apache.org/documentation/the-sling-engine/resources.html

https://experienceleague.adobe.com/en/docs/experience-manager-65/content/implementing/developing/int...

Avatar

Level 4

Hi @jayv25585659 

sling:resourceType:

 

  • The sling:resourceType property is primarily used to define the rendering or processing script associated with a component.
  • It points to the HTL (Sightly) script or other rendering logic that determines how the component’s content is displayed.
  • When AEM resolves a component, it looks for the specified resource type to determine how to render it.
  • Custom components often define their unique sling:resourceType to handle specific rendering requirements.

sling:resourceSuperType:

  • The sling:resourceSuperType property indicates inheritance in AEM.
  • When a component extends another component (similar to class inheritance), it can use sling:resourceSuperType to inherit properties, scripts, and other behavior from the parent component.
  • The resource super type forms a hierarchy of resources, where the default resource type (sling/servlet/default) acts as the root.
  • Core components often serve as resource super types. For example, when you create a custom component based on a core component, you set its sling:resourceSuperType to the core component’s resource type.
  • By doing this, your custom component inherits the core component’s behavior and can override specific aspects (such as rendering scripts or dialog definitions).

in simple layman's term 

  • Use resourceType when creating a specific component or template with unique features. eg(for specific chocolate cookie recipes)
  • Use resourceSuperType when you want to inherit common functionality from a shared parent design. eg(for the basic dough recipe shared among all cookies.)

Avatar

Level 2

sling:resourceType: Locate the resource to be used for rendering.

sling:resourceSuperType: Locate the resource to be inherited, allowing us to override some of the scripts.