You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by JCR <jc...@proxymit.net> on 2011/11/07 22:24:34 UTC
Nodetype dependent code
Hi,
I recently noticed on Lars' cheatsheet
(http://dev.day.com/docs/en/cq/current/developing/sling_cheatsheet.html), step
# 3, the term "Last resort".
I'd interpret this as possibility to attach specific code to a given
nodetype, i.e. scripts, or perhaps even bundles, could be linked to a
Nodetype. Now, I didn't find documentation on this specific topic.
So, my questions are:
It above assumption correct? If yes, where would I need to place the
code so it gets recognized by Sling to belong to nodetype X?
Thanks Pros,
Juerg
Re: Nodetype dependent code
Posted by Felix Meschberger <fm...@adobe.com>.
Hi,
Am 07.11.2011 um 22:24 schrieb JCR:
> Hi,
>
> I recently noticed on Lars' cheatsheet
> (http://dev.day.com/docs/en/cq/current/developing/sling_cheatsheet.html), step
> # 3, the term "Last resort".
>
> I'd interpret this as possibility to attach specific code to a given
> nodetype, i.e. scripts, or perhaps even bundles, could be linked to a
> Nodetype. Now, I didn't find documentation on this specific topic.
>
> So, my questions are:
> It above assumption correct? If yes, where would I need to place the
> code so it gets recognized by Sling to belong to nodetype X?
I do not exactly understand what you mean by "belong to nodetype X"...
The point in Lars' cheatsheet is that it is about getting the resource type of a JCR node based resource. Usually this is defined by the sling:resourceType property. Sometimes nodes don't have an explicit property and so we have defined some fallback mechanisms to make sure we always have a reasonable resource type. And so we said that ultimately the primary node type is used.
The most prominent example of using this fallback are nt:file nodes.
Hope this helps.
Regards
Felix
>
> Thanks Pros,
> Juerg
Re: Nodetype dependent code
Posted by JCR <jc...@proxymit.net>.
On 07.11.2011 23:12, Alexander Klimetschek wrote:
> On 07.11.11 22:24, "JCR"<jc...@proxymit.net> wrote:
>> It above assumption correct? If yes, where would I need to place the
>> code so it gets recognized by Sling to belong to nodetype X?
> A node type "nt:folder" is handled like a resource type "nt/folder".
>
> For example, /apps/nt/folder might be a location.
>
> Cheers,
> Alex
>
Thanks Alex & Felix for insightful explanation. Will try any time soon...
Juerg
Re: Nodetype dependent code
Posted by Alexander Klimetschek <ak...@adobe.com>.
On 07.11.11 22:24, "JCR" <jc...@proxymit.net> wrote:
>It above assumption correct? If yes, where would I need to place the
>code so it gets recognized by Sling to belong to nodetype X?
A node type "nt:folder" is handled like a resource type "nt/folder".
For example, /apps/nt/folder might be a location.
Cheers,
Alex
--
Alexander Klimetschek
Developer // Adobe (Day) // Berlin - Basel