Sling model two adapters, adapt problems

Avatar

Avatar

Aryan12345

Avatar

Aryan12345

Aryan12345

29-11-2018

Hi,

I have a sling model with both SlingHttpServletRequest and Resource as adaptables.

Couple of questions there.

1. I think the default adaptable is request (has the higher priority) since for any inject which depends on resource being the adaptable does not work until i put a Via("resource") there. Is this understanding correct?

2. When I adapt a resource (another model in the same component called from the same HTL file) to the model above, it throws (Suppressed: org.apache.sling.models.factory.MissingElementException: Could not inject private java.lang.String org.yadhu.core.test.MyComponent.parameter1). Basically it is asking me to make all those Injects optional which depend on request being adaptable. is this the expected behavior? Does this mean that whenever i have a model which has two adapters i need to make everything optional as I could potentially adapt both resource and request? please let me know.

thanks in advance all experts!

Yadhu

View Entire Topic

Avatar

Avatar

Aryan12345

Avatar

Aryan12345

Aryan12345

29-11-2018

Hi Arun,

One more thing... I have 6.4.. not sure what specification of SLing model is being used there.

type attribute does not seem to work with @Via.

type = ChildResource.class

is this true?

Via error2.jpg

Via error_edited.jpg

thanks,

Yadhu