6

I have page with name tst in content whose

sling:resourceType = news-portal/pages/test

page structure (under the /apps):

enter image description here

test has

sling:resourceSuperType = news-portal/pages/news-repo-main-page

in browser I type following URL:

http://localhost:4502/cf#/content/tst.selector.pdf.html

after this request I see content of selector.jsp

But I expected to see content of selector.pdf.jsp because it has more suitable much according my opinion.

  1. Can you explain how it works?

  2. Is there URL which can show content of selector.pdf.jsp ?

  3. Does the choice of content affects if test had sling:resourceType instead of sling:resourceSuperType or together? (I try to test but don't see affection)

P.S.

I know that answer somewhere here:

enter image description here

But I have problems with understanding

P.S.

log resolving:

      0 (2014-03-28 13:18:31) TIMER_START{Request Processing}
      0 (2014-03-28 13:18:31) COMMENT timer_end format is {<elapsed msec>,<timer name>} <optional message>
      0 (2014-03-28 13:18:31) LOG Method=GET, PathInfo=/content/tst.selector.pdf.html
      0 (2014-03-28 13:18:31) TIMER_START{ResourceResolution}
      0 (2014-03-28 13:18:31) TIMER_END{0,ResourceResolution} URI=/content/tst.selector.pdf.html resolves to Resource=JcrNodeResource, type=cq:Page, superType=null, path=/content/tst
      0 (2014-03-28 13:18:31) LOG Resource Path Info: SlingRequestPathInfo: path='/content/tst', selectorString='selector.pdf', extension='html', suffix='null'
      0 (2014-03-28 13:18:31) TIMER_START{ServletResolution}
      0 (2014-03-28 13:18:31) TIMER_START{resolveServlet(JcrNodeResource, type=cq:Page, superType=null, path=/content/tst)}
      0 (2014-03-28 13:18:31) TIMER_END{0,resolveServlet(JcrNodeResource, type=cq:Page, superType=null, path=/content/tst)} Using servlet /libs/foundation/components/primary/cq/Page/Page.jsp
      0 (2014-03-28 13:18:31) TIMER_END{0,ServletResolution} URI=/content/tst.selector.pdf.html handled by Servlet=/libs/foundation/components/primary/cq/Page/Page.jsp
      0 (2014-03-28 13:18:31) LOG Applying Requestfilters
      0 (2014-03-28 13:18:31) LOG Calling filter: org.apache.sling.bgservlets.impl.BackgroundServletStarterFilter
      0 (2014-03-28 13:18:31) LOG Calling filter: org.apache.sling.rewriter.impl.RewriterFilter
      0 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.wcm.core.impl.WCMRequestFilter
      0 (2014-03-28 13:18:31) LOG Calling filter: org.apache.sling.i18n.impl.I18NFilter
      0 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.theme.impl.ThemeResolverFilter
      0 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.wcm.foundation.forms.impl.FormsHandlingServlet
      1 (2014-03-28 13:18:31) LOG Calling filter: org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter
      1 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.wcm.mobile.core.impl.redirect.RedirectFilter
      1 (2014-03-28 13:18:31) LOG RedirectFilter did not redirect (MobileUtil.isMobileResource() returns false)
      1 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.wcm.core.impl.warp.TimeWarpFilter
      1 (2014-03-28 13:18:31) LOG Applying Componentfilters
      1 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.wcm.core.impl.WCMComponentFilter
      1 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.wcm.core.impl.WCMDebugFilter
      1 (2014-03-28 13:18:31) TIMER_START{/libs/foundation/components/primary/cq/Page/Page.jsp#0}
      1 (2014-03-28 13:18:31) LOG Including resource JcrNodeResource, type=news-portal/pages/test, superType=null, path=/content/tst/jcr:content (SlingRequestPathInfo: path='/content/tst/jcr:content', selectorString='selector.pdf', extension='html', suffix='null')
      1 (2014-03-28 13:18:31) TIMER_START{resolveServlet(JcrNodeResource, type=news-portal/pages/test, superType=null, path=/content/tst/jcr:content)}
      1 (2014-03-28 13:18:31) TIMER_END{0,resolveServlet(JcrNodeResource, type=news-portal/pages/test, superType=null, path=/content/tst/jcr:content)} Using servlet /apps/news-portal/pages/news-repo-main-page/selector.jsp
      1 (2014-03-28 13:18:31) LOG Applying Includefilters
      1 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.wcm.core.impl.WCMComponentFilter
      1 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.wcm.core.impl.WCMDebugFilter
      1 (2014-03-28 13:18:31) TIMER_START{/apps/news-portal/pages/news-repo-main-page/selector.jsp#1}
      2 (2014-03-28 13:18:31) LOG Found processor for post processing ProcessorConfiguration: {contentTypes=[text/html],order=-1, active=true, valid=true, processErrorResponse=true, pipeline=(generator=Config(type=htmlparser, config={}), transformers=(Config(type=linkchecker, config={}), Config(type=mobile, config=org.apache.sling.jcr.resource.JcrPropertyMap@25c0b221), Config(type=mobiledebug, config=org.apache.sling.jcr.resource.JcrPropertyMap@deea7e4), Config(type=contentsync, config=org.apache.sling.jcr.resource.JcrPropertyMap@2f5070e1), serializer=Config(type=htmlwriter, config={}))}
      2 (2014-03-28 13:18:31) TIMER_END{1,/apps/news-portal/pages/news-repo-main-page/selector.jsp#1}
      2 (2014-03-28 13:18:31) TIMER_END{1,/libs/foundation/components/primary/cq/Page/Page.jsp#0}
      2 (2014-03-28 13:18:31) TIMER_END{2,Request Processing} Request Processing

UPDATE

I noticed that if I create following structure and send request to

http://localhost:4502/cf#/content/tst.selector.pdf.html

enter image description here

I see content of pdf.jsp

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710

1 Answers1

7

In Sling there are two things: content (stored under /content) and code (stored under /apps). Content contains only properties data. There should be no logic, no JSP (or any other code) and selector information under /content.

On the other hand, /apps subtree contains scripts used to render the content. Such scripts are usually called components. sling:resourceType property (set for a piece of data, under /content) is a link between content and component. This is the way how content may say "following component should be used to display me".

sling:resourceSuperType has a different function. It is a property set on the component resource (under /apps), used to mark that this component should inherit JSPs and from another one. This property allows to create component hierarchy.

According to link in the comment it is also possible to put sling:resourceSuperType in the data component under /content. In this case, we force the component referenced in sling:resourceType to inherit from component referenced in sling:resourceSuperType. I don't know any use-case for that, tough.

In your case, please try creating following structure:

  • /content/test
    • sling:resourceType = news-portal/pages/test
  • /apps/news-portal/pages/test
    • component main resource, no special properties
  • /apps/news-portal/pages/test/test.jsp
    • main JSP file
  • /apps/news-portal/pages/test/selector.jsp
    • JSP used for selector
  • /apps/news-portal/pages/test/selector/pdf.jsp
    • selector + pdf extension
Tomek Rękawek
  • 9,204
  • 2
  • 27
  • 43
  • **properties data** What does it mean? – gstackoverflow Mar 28 '14 at 19:15
  • My question was about using **sling:resourceType** for components elements. this make sense ? – gstackoverflow Mar 28 '14 at 19:22
  • I read this link: https://dev.day.com/docs/en/cq/5-5/developing/the_basics.html#Sling%2520Request%2520Processing and I don't understand what is discussed in end of chapter **Locating the script** in subTitle **For example:** – gstackoverflow Mar 28 '14 at 19:25
  • at this example **/y** has and **sling:resourceSuperType** and **sling:resourceType** What the sense make such? – gstackoverflow Mar 28 '14 at 19:35
  • **sling:resourceType** doesn't make sense on the component elements and won't work. Apparently, **sling:resourceSuperType** may be set on the data resource too, but I don't know any use case for doing that. – Tomek Rękawek Mar 29 '14 at 09:45
  • Do I understand you correctly? in topic update you wrote about case if element under **/content** has both: and **sling:resourceSuperType** and **sling:resourceType** but if element under the **/content** has only **sling:resourceSuperType** - it hasn't sense ? Sorry - I understand very little of English – gstackoverflow Mar 29 '14 at 11:32
  • please reply. I really need it. – gstackoverflow Mar 30 '14 at 11:42
  • Yes, it made no sense to add only a `sling:resourceSuperType` property to the content resource. – Tomek Rękawek Mar 31 '14 at 08:46
  • _"sling:resourceSuperType has a different function. It is a property set on the component resource (under /apps), used to mark that this component should inherit JSPs and from another one. This property allows to create component hierarchy."_ Would the content of super type resource component be rendered in page when using the component which has `sling:resourceSuperType` property. – Sandeep Kumar Jul 27 '16 at 08:48