Problem with @inject annotation in a sling model
Hi everyone,
I have a issue with @inject annotation, I try to inject the Resource object inside a Sling Model, but when I debug the code it's null.
This is part of my code:
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.commons.json.JSONArray;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.apache.sling.models.annotations.Default;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Optional;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.servlet.jsp.PageContext;
@Model(adaptables = { Resource.class, SlingHttpServletRequest.class })
public class ProductFilter extends AbstractComponent {
@Inject
private Resource resource;
Could someone help me with this issue?
