creating a component
create a component through CRX
Foo.java
package apps.training.components.foo;
import com.adobe.cq.sightly.WCMUse;
public class Foo extends WCMUse {
private String foo;
@Override
public void activate() throws Exception {
foo = "foo";
}
public String getFoo() {
return foo;
}
}
- foo.html
<div data-sly-use.foo="apps.training.components.Foo">${foo.foo}</div>
Note that the package here is a "Must-have", or you'll get a java.lang.ClassNotFoundException
.
The package might indicate the actual folder of the Java file.
use the component
<div>
<div data-sly-resource="${'foo' @ resourceType='training/components/foo'}">
</div>