How to modify @Inject getter (passed from AEM ) in interface

208 Views Asked by At
@Inject
String getGoToFavoritesButtonLink();

is in the interface and not class. I want to modify its value to be something like getGoToFavoritesButtonLink().concat(".html"); so that URL can be externalized. How can this be done without any setter?

Java:

@Model(adaptables = org.apache.sling.api.resource.Resource.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL) 
public interface WebshopFavoriteListConfigModel {
@Inject 
String 
getGoToFavoritesButtonLink();
}

HTML:

<a href="${model.webshopFavoriteListConfigModel.goToFavoritesButtonLink}"/>
1

There are 1 best solutions below

0
Vlad On

You can set the extension using the extension HTL option:

<a href="${model.webshopFavoriteListConfigModel.goToFavoritesButtonLink @ extension='html'}">...</a>

You can review all URI manipulation options in the HTL Specification.