How can I get the request object in SlingModel to know the requested page path in @PostConstruct method?
Hi,
I have a requirement to get the current browser URL to identify the type of URL, for doing so we need the request object also in the SlingModel with Resource model.
We are doing like as below,
After adding 2 adaptables classes like,
@Model(adaptables = { SlingHttpServletRequest.class, Resource.class })
@Inject
private SlingHttpServletRequest slingHttpServletRequest;
@Inject
private Resource resource;
Still getting errors like,
26.09.2016 10:47:47.111 *WARN* [0:0:0:0:0:0:0:1 [1474867052138] GET /content/abc/homepage.html HTTP/1.1] org.apache.sling.models.impl.ModelAdapterFactory Required properties [private org.apache.sling.api.SlingHttpServletRequest org.abc1.abc.core.model.hero.HeroComponentModel.slingHttpServletRequest] on model class class org.abc1.abc.core.model.hero.HeroComponentModel were not able to be injected.
26.09.2016 10:47:47.111 *WARN* [0:0:0:0:0:0:0:1 [1474867052138] GET /content/abc/homepage.html HTTP/1.1] org.apache.sling.models.impl.ModelAdapterFactory Required properties [private org.apache.sling.api.SlingHttpServletRequest org.abc1.abc.core.model.hero.HeroComponentModel.slingHttpServletRequest] on model class class org.abc1.abc.core.model.hero.HeroComponentModel were not able to be injected.
26.09.2016 10:47:47.123 *WARN* [0:0:0:0:0:0:0:1 [1474867052138] GET /content/abc/homepage.html HTTP/1.1] org.apache.sling.models.impl.ModelAdapterFactory Required properties [protected org.apache.sling.api.resource.Resource org.abc1.abc.core.model.common.AbstractNodeNameModel.resource, private org.apache.sling.api.resource.Resource org.abc1.abc.core.model.hero.HeroComponentModel.currentResource] on model class class org.abc1.abc.core.model.hero.HeroComponentModel were not able to be injected.
Please let me know on this ?
Thanks,
Mayur