What would be reason for Sightly execption: cannot get default description. | Community
Skip to main content
Level 3
November 17, 2023
Solved

What would be reason for Sightly execption: cannot get default description.

  • November 17, 2023
  • 5 replies
  • 1344 views

I have created a multifield component with a sling model. I cannot render the content using sling models.

Error: org.apache.sling.api.SlingException: Cannot get DefaultSlingScript:

=============== SocialShareItemsModel =====================

import org.apache.sling.api.resource.Resource;

import org.apache.sling.models.annotations.DefaultInjectionStrategy;

import org.apache.sling.models.annotations.Model;

import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;

 

@Model(adaptables = Resource.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)

public class SocialShareItemsModel {

 

@ValueMapValue

private String socialicon;

 

@ValueMapValue

private String socialMediaUrl;

 

public String getSocialicon() {

return socialicon;

}

 

public String getSocialMediaUrl() {

return socialMediaUrl;

}

}

=============================SocialShareModel======================================

import java.util.ArrayList;

import java.util.List;

import org.apache.sling.api.SlingHttpServletRequest;

import org.apache.sling.models.annotations.DefaultInjectionStrategy;

import org.apache.sling.models.annotations.Model;

import org.apache.sling.models.annotations.injectorspecific.ChildResource;

 

@Model(adaptables = SlingHttpServletRequest.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)

public class SocialShareModel {

 

@ChildResource

private List<SocialShareItemsModel> mediaitems = new ArrayList<SocialShareItemsModel>();

 

public List<SocialShareItemsModel> getMediaitems() {

return mediaitems;

}

}

=================================== Sightly====================

 <sly data-sly-use.model="com.sample.core.models.SocialShareModel">
<sly-data-sly.list="${model.mediaitems}">
<a class="icon-link" href="${item.socialMediaUrl}">
<img src="${item.socialIcon}">
</a>
</sly>
</sly>

 

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 MayurSatav

Hi @anilkumar9 ,

 

Checkout this blog for detailed understanding on multi-field dialog. 

5 replies

MayurSatav
Community Advisor and Adobe Champion
MayurSatavCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
November 17, 2023

Hi @anilkumar9 ,

 

Checkout this blog for detailed understanding on multi-field dialog. 

Mayur Satav | www.mayursatav.in
arunpatidar
Community Advisor
Community Advisor
November 17, 2023

Hi @anilkumar9 
What issue are you facing?

Arun Patidar
MarkusBullaAdobe
Adobe Employee
Adobe Employee
November 17, 2023

Hi @anilkumar9!

Would you mind sharing the error/exception including stack traces from the error.log file for this issues? This would help with further analysis and support.

partyush
Community Advisor
Community Advisor
November 17, 2023

Hi @anilkumar9 

 

It looks like there might be a typo in your Sightly code where you're trying to access the socialicon property. The property in your Sling model is named socialicon, but in your Sightly code, you're trying to use item.socialIcon.

 

<sly data-sly-use.model="com.sample.core.models.SocialShareModel"> <sly data-sly-list="${model.mediaitems}"> <a class="icon-link" href="${item.socialMediaUrl}"> <img src="${item.socialicon}"> <!-- Corrected property name --> </a> </sly> </sly>

 

Here, I corrected the property name from socialIcon to socialicon to match your Sling model. Make sure to use the exact property names as defined in your model.

If the issue persists, you may also want to check if the mediaitems list is not null in your Sightly code to avoid potential null pointer exceptions:

<sly data-sly-use.model="com.sample.core.models.SocialShareModel"> <sly data-sly-list="${model.mediaitems}"> <sly data-sly-test="${item != null}"> <a class="icon-link" href="${item.socialMediaUrl}"> <img src="${item.socialicon}"> </a> </sly> </sly> </sly>
 

This checks if item is not null before trying to access its properties.

 

 

Also check your error.log file and share the complete error report so that we can debug it in better way. 

Level 3
November 21, 2023

Thank you for your willingness to help; your support means a lot

kautuk_sahni
Community Manager
Community Manager
November 20, 2023

@anilkumar9 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni
Level 3
November 21, 2023

yes, @kautuk_sahni those suggestions are really helpful. Thanks!