please try to use use @Inject or even better @SlingObject on the "request" 
variable instead of @Self - then is should work.

for the "resource" parameter i would prefer @SlingObject as well instead of 
@Inject to make it more explicit and a litte bit more efficient (no need it 
iterate over all potential injectors internally to find the right match).

stefan


>-----Original Message-----
>From: Oliver Lietz [mailto:[email protected]]
>Sent: Thursday, April 14, 2016 9:42 AM
>To: [email protected]
>Subject: [Models] Injecting from two sources
>
>Hi,
>
>is it somehow possible to inject both a resource and a request where the
>request is optional and should not break injection when not available?
>
>@Model(adaptables = {Resource.class, SlingHttpServletRequest.class})
>public class MyModel {
>
>    @Inject
>    private Resource resource;
>
>    @Self
>    @Optional
>    private SlingHttpServletRequest request;
>
>}
>
>In my case injection fails with SlingHttpServletRequest not adaptable from
>JcrNodeResource.
>
>Thanks,
>O.
>


Reply via email to