In AEM, I have a Use class A which extends WCMUsePojo
. It has one activate()
method with @Override
annotation where I read the property (lets say product) and assign to variable. Also, I have a getter method to read the property. Now, there is another class B which extends the Class A and has activate()
method with @Override
annotation. In activate method I am reading one more property.
Now, from HTL , I refer the Class B, and was trying to get "product property" (assuming that this property would be available in Class B via inheritance), But I am getting null value. But when I change the property modifier to static
in Class A, then it works fine.
See the code below.
public class ClassA extends WCMUsePojo {
private String product;
@Override
public void activate() throws Exception {
product = getProperties().get(“product”, "");
}
public String getProduct() {
return product;
}
}
public class ClassB extends ClassA {
private String lotno;
@Override
public void activate() throws Exception {
lotno = getProperties().get(“lotno”, "");
}
public String getLotno() {
return lotno;
}
}
<div data-sly-use.productDetails="test.sample.ClassB"/>
${productDetails.product}
${productDetails.product}
is null
unless I change the product property to static in ClassA
. Can somebody explain why is that so?