Delegation Pattern for Title Component - what get method needs an Override?
Using AEM 6.5 SP1. I followed the basic example here: Delegation Pattern for Sling Models · adobe/aem-core-wcm-components Wiki · GitHub
The example extended the title component and overwrote the getText() method in a PageHeadline class. Do you also need to override all the other get methods of the OOTB delegated title component to use them in the HTL? Or should the Delegation Pattern provide them all?
Using just the example, the Link functionality is not working properly. The "page 1" link is just a proxy of the OOTB core title component v2. The "Overriding the page 1" text is from the pageheadline component overriding just the getText() and getType() methods as per the example. You can see the link is not working.

If I add an additional override for getLinkURL() to the PageHeadline.java, the link work starts working.
@Override
public String getLinkURL() {
return title.getLinkURL();
}

I'm seeing the same thing with the JSON exporter. With the example, the JSON is always the OOTB title component and does not show the overridden text from the pageheadline.
":items": {
"title": {
"linkDisabled": false,
"type": "h2",
"linkURL": "/content/my-testing/en.html",
"text": "page 1",
":type": "my-testing/components/content/title"
},
"pageheadline": {
"linkDisabled": false,
"type": "h2",
"linkURL": "/content/my-testing/en.html",
"text": "page 1",
":type": "my-testing/components/content/pageheadline"
}
}
I updated the PageHeadline.java code to add the adapter for ComponentExporter.class.
adapters = {Title.class, ComponentExporter.class}
Now pageheadline only has the two methods getText() and getType() that were overriden in PageHeadline.java. Should I need to add all the other methods to get them to show up in the JSON? That does work, but now I have to add override stubs for every get method. Or should the values come through the delegation?
":items": {
"title": {
"linkDisabled": false,
"type": "h2",
"linkURL": "/content/my-testing/en.html",
"text": "page 1",
":type": "my-testing/components/content/title"
},
"pageheadline": {
"type": "h2",
"text": "Overriding the page 1"
}
}