Exception when extending Sightly page component | Community
Skip to main content
salvadorm142499
Level 3
June 16, 2016
Solved

Exception when extending Sightly page component

  • June 16, 2016
  • 7 replies
  • 3324 views

Hi all,

Using AEM 6.2, I have created a template /apps/myproject/templates/mytemplate and a page component for that template at /apps/myproject/components/pages/basepage. Set the sling:resourceSuperType of this component to be wcm/foundation/components/page. Create now a page based on this template and it throws an exception:

org.apache.sling.api.scripting.ScriptEvaluationException: org.apache.sling.scripting.sightly.SightlyException: org.apache.sling.api.scripting.ScriptEvaluationException: org.apache.sling.scripting.sightly.SightlyException: Identifier com.day.cq.wcm.foundation.TemplatedContainer cannot be correctly instantiated by the Use API

The issue appears at body.html when using the Java USE Api at <sly data-sly-use.body="body.js" data-sly-use.templatedContainer="com.day.cq.wcm.foundation.TemplatedContainer"/>

Which is the purpose of templatedContainer object? Why is it throwing the exception? I can not find the source code of TemplatedContainer Java class :(

Cheers,

Salva.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

If you want to use a Sightly page component - try using the one built for you when you use Maven 10. See: 

https://helpx.adobe.com/experience-manager/using/first-arch10.html

Use that one as a starting point. 

7 replies

smacdonald2008
smacdonald2008Accepted solution
Level 10
June 16, 2016

If you want to use a Sightly page component - try using the one built for you when you use Maven 10. See: 

https://helpx.adobe.com/experience-manager/using/first-arch10.html

Use that one as a starting point. 

Ratna_Kumar
Level 10
June 16, 2016

Hi Salva,

As per scott stated, you can use default Sightly Page component using Maven 10 archetype plugin.

See this article which creates the AEM project on maven archetype 10 plugin: https://helpx.adobe.com/experience-manager/using/first-arch10.htmlThis includes default Sightly page component.

Hope this helps!

Thanks,
Ratna Kumar.

edubey
Level 10
June 16, 2016

Hi,

Do refer to the documentation of this class @ https://docs.adobe.com/docs/en/aem/6-2/develop/ref/javadoc/com/day/cq/wcm/foundation/TemplatedContainer.html

templatedContainer will help you to get access the method of this class which I feel are

             
StringgetNewResourceType() 
List<Resource>getStructureResources() 
  

try this

 <div data-sly-use.templatedContainer="com.day.cq.wcm.foundation.TemplatedContainer">

        ${templatedContainer.newResourceType}

</div>

Lokesh_Shivalingaiah
Level 10
June 16, 2016

It looks like you are using data-sly-use attribute multiple times in a single <sly> tag. Also try using "data-sly-use" in <div> tag instead of <sly> tag.

salvadorm142499
Level 3
June 17, 2016

bsloki wrote...

It looks like you are using data-sly-use attribute multiple times in a single <sly> tag. Also try using "data-sly-use" in <div> tag instead of <sly> tag.

 

 

Hi bsloki,

I think it is possible. Moreover, the sightly page component under foundation contains two data-sly-use in a single <sly> tag.

Cheers,

Salva.

salvadorm142499
Level 3
June 17, 2016

Hi edubey,

The issue appears when the object is instantiated instead of when the object calls its methods... still throwing exceptions.

Cheers,

Salva. 

salvadorm142499
Level 3
June 17, 2016

Hi smacdonald,

This answer does not really solve my problem as I can not use the capabilities of the 'TemplatedContainer' object but, It works :)

Cheers,

Salva.