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 Feike,

how do you mean "what is done first"?

Does it mean what you put as first in adaptable list (in annotation)? does not matter... either ways it gives the request the priority...

Would be great if you can explain further. thanks.