Hi Team,
I would like to use sling models with WCMUse/WCMUsePojo class. For I have written the below code -
@Model(adaptables = Resource.class)
public class SampleSlingModel extends WCMUse {
private static Logger LOG = LoggerFactory.getLogger(SampleSlingModel.class);
@Inject
private String title;
@Override
public void activate() throws Exception {
LOG.info("SampleSlingModel.activate():Title:" + title);
}
public String getTitle() {
return title;
}
}
I'm able to get the value of title in component's sightly HTML using get method but the activate method is not invoked. If a class is extending WCMUse should call activate() but it is not. Can you please help me in this?
I tried to put @PostConstruct instead of @Override and activate method is called as sling model is treated it as just another method.
Is it best practice to proceed with this as the methods which are there in WCMUse/WCMUsePojo will not be available in the sling models?
Please suggest.
Thanks,
AryA.