Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

data-sly-call not invoked in sightly

Avatar

Level 5

Hi

I have a component SightlyTest in which i have following file :

SightlyTest.html : 

Hello Sightly         ${properties.description} <div data-sly-use.extra="extra1.html">     <div data-sly-call="${extra @ text=properties.description}"></div> </div>

extra1.html : 

<template data-sly-template.extra="${@ text}"           data-sly-use.extraHelper="${'ExtraHelper' @ text=text}">           <p>${extraHelper.reversedText}</p> </template>

ExtraHelper.java :

package apps.AEMProject.components.content.SightlyTest; import com.adobe.cq.sightly.WCMUse; public class ExtraHelper extends WCMUse { private String reverseText; @Override public void activate() throws Exception { String text = get("text", String.class); reverseText = new StringBuffer(text).reverse().toString(); } public String getReverseText() { return reverseText; } }

But noting shows as output, what i can see only Hello Sightly . ${properties.description} shows the value of property.

Any Idea.

1 Accepted Solution

Avatar

Correct answer by
Employee

Can you change this to all lowercase, and then also change the package of your Java-class to all lowercase?

To me this is likely the cause...

View solution in original post

7 Replies

Avatar

Employee

hi ,

Can you try this?

<div data-sly-call="${extra.extra @ text=properties.description}"></div>

You have data-sly-use.extra, and your template is also called extra.

Avatar

Level 5

Feike Visser wrote...

hi ,

Can you try this?

<div data-sly-call="${extra.extra @ text=properties.description}"></div>

You have data-sly-use.extra, and your template is also called extra.

 

 Hi I tried this, its not working. Also now i have changed the template file name to extra1.html but still no success,

Thanks

Avatar

Employee

This works perfectly with me...

<div data-sly-use.extra="extra1.html">

    <div data-sly-call="${extra.extra @ text='hello'}"></div>

</div>

 

extra1.html:

 

<template data-sly-template.extra="${@ text}">

          <p>hello from template</p>

</template>

Can you first try this?

Avatar

Level 5

Feike Visser wrote...

This works perfectly with me...

<div data-sly-use.extra="extra1.html">

    <div data-sly-call="${extra.extra @ text='hello'}"></div>

</div>

 

extra1.html:

 

<template data-sly-template.extra="${@ text}">

          <p>hello from template</p>

</template>

Can you first try this?

 

Yes, This works, But the issue was in the invocation of ExtraHelper class. 

<template data-sly-template.extra="${@ text}" data-sly-use.extraHelper="${'ExtraHelper' @ text=text}"> <p>${extraHelper.reversedText}</p> </template>

which is still there, Its not initializing extraHelper with the text 'hello' that we are passing above, the output should come as olleh. But nothing shows as output. Even when i write System.out.println(":::::"); its doesn't write anything to stdout.log.

Thanks

Avatar

Employee

Ok, now we are getting somewhere :-)

What is the path of your component?

Avatar

Level 5

Feike Visser wrote...

Ok, now we are getting somewhere :-)

What is the path of your component?

 

This is component path : /apps/AEMProject/components/content/SightlyTest

Avatar

Correct answer by
Employee

Can you change this to all lowercase, and then also change the package of your Java-class to all lowercase?

To me this is likely the cause...