Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

need to call the expense fragment data in service call.

Avatar

Level 3

Hi,

 

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

 

Thanks,

Mohan 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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");

 

 

 

 

View solution in original post

3 Replies

Avatar

Community Advisor

Hi @mohanasundaramp,

 

Please find a similar post here

 

Hope this helps.

 

Thanks,

Kiran Vedantam.

Avatar

Correct answer by
Community Advisor

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");