Hi everyone,
I am following this page(Delegation Pattern for Sling Models · adobe/aem-core-wcm-components Wiki · GitHub)and try to customize title component,but it still returns the originial title.
Is there something else i need to do besides create pageHeadline component in ui.apps and model file in models folder?For example add something into the core/pom.xml or create a new title htl file in crxde lite?
Thanks in advance!
My code below:
training\ui.apps\src\main\content\jcr_root\apps\training\components\pageHeadline\.content.xml
<?xml version="1.0" encoding="UTF-8"?>
jcr:primaryType="cq:Component"
jcr:title="Page Headline"
jcr:description="Display Page Heading"
sling:resourceSuperType="core/wcm/components/title/v3/title"
componentGroup="TrainingProject - Content"/>
training\core\src\main\java\com\adobe\training\core\models\PageHeadlineModel.java
package com.adobe.training.core.models;
import com.adobe.cq.wcm.core.components.models.Title;
import com.day.cq.wcm.api.Page;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Via;
import org.apache.sling.models.annotations.injectorspecific.ScriptVariable;
import org.apache.sling.models.annotations.injectorspecific.Self;
import org.apache.sling.models.annotations.via.ResourceSuperType;
@Model(adaptables = SlingHttpServletRequest.class, adapters = Title.class,resourceType = "training/components/pageHeadline")
public class PageHeadlineModel implements Title {
@ScriptVariable
private Page currentPage;
@Self @Via(type = ResourceSuperType.class)
private Title title;
@Override
public String getText() {
return "new title"+title.getText();
}
}