Expand my Community achievements bar.

SOLVED

coerceToString is an internal method

Avatar

Level 2

Hi 

        I am getting the below error in my pages from my page.html. Does anyone already faced this issue before ?

HTML

<!doctype html>
<html lang="en" class="js csscolumns svg">
    <head>
        <sly data-sly-include="partials/head.html" data-sly-unwrap/>
        <sly data-sly-include="partials/headlibs.html" data-sly-unwrap/>
    </head>
    <body class="page ${currentPage.template.name}">
        <sly data-sly-include="partials/main.html" data-sly-unwrap/>
        <sly data-sly-include="partials/footlibs.html" data-sly-unwrap/>
    </body>
</html>

Exception:

org.apache.sling.scripting.sightly.SightlyException: coerceToString is an internal method at io.sightly.java.impl.slingAdapter.ObjectModelAdapter.coerceToString(ObjectModelAdapter.java:43) at com.adobe.cq.sightly.internal.extensions.IncludeExtension$1.call(IncludeExtension.java:63) at io.sightly.java.impl.graniteAdapter.RuntimeExtensionAdapter.call(RuntimeExtensionAdapter.java:37) at org.apache.sling.scripting.sightly.impl.engine.runtime.RenderContextImpl.call(RenderContextImpl.java:89)

 

TIA

Veena

1 Accepted Solution

Avatar

Correct answer by
Employee

${currentPage.template} only works with the right permissions, nothing to do with the dispatcher.

Basically: never use getTemplate() :-)

View solution in original post

5 Replies

Avatar

Level 10

Create a new project using Maven 10 project. 

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

Take a look at some of the default HTML pages -- for example:

<html lang="en">
    <head>
        <sly data-sly-include="partials/head.html" data-sly-unwrap/>
        <sly data-sly-include="partials/headlibs.html" data-sly-unwrap/>
    </head>
    <body class="page ${currentPage.template.name}">
        <sly data-sly-include="partials/main.html" data-sly-unwrap/>
        <sly data-sly-include="partials/footlibs.html" data-sly-unwrap/>
    </body>
</html>

You should not be seeing that error. Compare the code on that project with yours. 

Avatar

Level 2

Thanks for the quick response scott. I installed the package in a fresh instance and all started working fine. I am not sure what has happened to the instance before

Avatar

Level 10

Could have been an outdated file or something. Glad its working. 

Avatar

Level 8

Also you shouldn't use $[currentPage.template} - it'll be blocked on the dispatcher due to permissions.

Avatar

Correct answer by
Employee

${currentPage.template} only works with the right permissions, nothing to do with the dispatcher.

Basically: never use getTemplate() :-)