need to call the expense fragment data in service call. | Community
Skip to main content
New Participant
February 22, 2021
Solved

need to call the expense fragment data in service call.

  • February 22, 2021
  • 3 replies
  • 1253 views

Hi,

 

Any one help how to read in experience fragment data into service level.

 

Thanks,

Mohan 

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 BrianKasingli

Reading an experience fragment from a OSGI service will be the same way as accessing a resource and valueMap from the CRXDE.

 

Optional<Resource> contentFragmentCarousel = Optional.ofNullable(resolver.getResource("/content/experience-fragments/my-site/offers/latest-offers/master/jcr:content/root/carousel")); String myCustomPropValue = contentFragmentCarousel .map(Resource::getValueMap) .map(e -> e.get("myCustomProp", String.class)) .orElse("defaultText");

 

 

 

 

3 replies

BrianKasingli
New Participant
February 22, 2021

DELETED

BrianKasingli
BrianKasingliAccepted solution
New Participant
February 22, 2021

Reading an experience fragment from a OSGI service will be the same way as accessing a resource and valueMap from the CRXDE.

 

Optional<Resource> contentFragmentCarousel = Optional.ofNullable(resolver.getResource("/content/experience-fragments/my-site/offers/latest-offers/master/jcr:content/root/carousel")); String myCustomPropValue = contentFragmentCarousel .map(Resource::getValueMap) .map(e -> e.get("myCustomProp", String.class)) .orElse("defaultText");

 

 

 

 

Kiran_Vedantam
New Participant
February 22, 2021

Hi @mohanasundaramp,

 

Please find a similar post here

 

Hope this helps.

 

Thanks,

Kiran Vedantam.