Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Cannot get DefaultSlingScript: data-sly-use needs to be passed an identifier

Avatar

Level 5

Hi

When I add to my template

<sly data-sly-use.storeLink="${'android' == model.device ? model.appleStoreLink : model.googlePlayLink}"></sly>

I get the following error

Cannot get DefaultSlingScript: org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: data-sly-use needs to be passed an identifier

My model isDevice looks like:

public String isDevice() {
String userAgent = request.getHeader("user-agent");

if (userAgent.contains("iPhone")) {
return "ios";
} else if(userAgent.contains("Android")){
return "android";
} else {
return StringUtils.EMPTY;
}
}

Any suggestions what I am doing wrong?

  

2 Replies

Avatar

Level 5

Hi,

Will this always evaluate:

 

<sly data-sly-test.storeLink="${'android' == model.device ? model.appleStoreLink : model.googlePlayLink}"></sly>

Why does the  

data-sly-use

 throw an error?