How to use sling model request object from one model class to another
Hi i am new to AEM, and stuck with one issue: I want use the request object of DemoModel, into CallToActionModel to call one of the util methods, but this does not seems to work, can anyone please help with this, below is the code snippet
@Model(adaptables = { SlingHttpServletRequest.class,
Resource.class }, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
@Exporter(name =jackson, extensions = json)
public class DemoModel extends WebComponentModel{
@SlingObject
private SlingHttpServletRequest request;
@ChildResource
@Expose
private List<DemoModelList> site;
}
Model(adaptables = { SlingHttpServletRequest.class,
Resource.class }, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class DemoModelList extends WebComponentModel {
@ChildResource
@Expose
private List<CallToActionModel> links;
}
@Model(adaptables = { SlingHttpServletRequest.class, Resource.class }, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class CallToActionModel extends WebComponentModel {
@Inject
private SlingHttpServletRequest request;
@Default(booleanValues = false)
@ValueMapValue
@Expose
@Getter
@Setter
private boolean isSiteCheck;
@Override
@PostConstruct
protected void init() {
isDealerSite = isSiteCheck && AEMUtils.isSite(request);
super.init();
}

