AEM - Sling model - Unable to @Inject on 6.5.12 | Community
Skip to main content
Level 9
June 21, 2022

AEM - Sling model - Unable to @Inject on 6.5.12

  • June 21, 2022
  • 1 reply
  • 1767 views

All,

 

On 64 the below logic resolved to the node multi n case of [A] or it returned empty in case of [B] but on 65 , this returns the parent node[B] if node multi is not found else it returns as in [A] that is expected. Tried @Named but didn't help. Please let me know if i am missing something

 

 

I want it to resolve to multi only. This was working on 64 and now we migrated to 6.5.12 and it is broken. 

 

<sly data-sly-use.carousel="com.test.aem.core.components.carouselController">

 

@Model(adaptables = Resource.class)
public class CarouselController {

@586265
@7392697
public Resource multi;

 

 

 

The content structure 

For [A] - with "multi" node's presence, ${carousel.multi.path} is the path to "multi" node

[A]

/content/X/..
      /group

        /slides

        /multi

 

For [B] - where "multi" node is missing,  ${carousel.multi.path} is the path to "group" node

[B]

The content structure is 

/content/X/..
      /group

        /slides

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

SantoshSai
Community Advisor
Community Advisor
June 21, 2022

Hi @nitrohazedev ,

Have you tied with 

@SlingObject
@Optional
public Resource multi;

ignore if already!

Regards,

Santosh 

Santosh Sai
Level 9
June 21, 2022

Hi @santoshsai , thanks for the input, it did not help. I hadn't tried it per say until you brought it out but in vain
@SlingObject
@Optional

Level 9
June 21, 2022

@nitrohazedev About annotation please check here: https://sling.apache.org/documentation/bundles/models.html

About solution to your problem please see if these helps: https://allaembykiran.wordpress.com/2021/09/06/sling-model-retrieving-properties-of-child-resources/

https://allaembykiran.wordpress.com/2021/01/13/nested-multi-field/

 


Hi @santoshsai  nothing but childresource helped. Adapting to resource itself .. I see many use it online the same way. I can’t seem to understand why it worked in 6.2 and not in 6.5.12 and now wondering if @childresource with adapting to resource is the right way to go although it works for me

 

also what gets adapted to is the carousel parent node and I need it to say, ..yes I found the node multi or not