Text formatting not working:
Views
Replies
Total Likes
Well, first of all you need to make sure your SlingModel is initiated... and then your using the correct Sling Annotations to pull jcr properties into that component. like @ValueMapValue private String text;... next, you need to ensure that your TextUtil is also working as expected.
HTL
<a href="${model.urlLink}">${model.formattedText}</a>
Sightly
...
@ValueMapValue
private String urlLink;
@ValueMapValue
private String text;
public String getUrl() {
return LinkUtils.formatLink(urlLink);
}
public String getFormattedText() {
return TextUtil.reformatText(text);
}
for testing sale, making sure if your Sling Model is returning string from the backend as expected, you can do something like this:
public String getFormattedText() {
return "I love sourcedcode.com!";
}
References (Sling Model Annotations CheatSheet): https://sourcedcode.com/blog/aem/aem-sling-model-injectors-annotations-cheat-sheet-reference-guide#V...
Views
Replies
Total Likes
Handled correctly only but formatting not works:
Views
Replies
Total Likes
Hello, your link TextUtil must be not working as expected….
you can simple return hard coded text, to see if the method is retuning anything correct, and if so, must be your TextUtil. Something is not working there.
public String getFormattedText() {
return "I love sourcedcode.com!";
}
Views
Replies
Total Likes
I tested it. Yes, there might be some issues with TextUtil or somewhere else but not fully sure as it works in other places.
Is there any other option to handle this formatting?
Views
Replies
Total Likes
Hey, sorry nope, your own custom solution is required.
Views
Replies
Total Likes
When you say it is not working. Could you elaborate that a little ?
Views
Replies
Total Likes
For example, the formatting is applied to the text field which is working fine in 1 component but not working for the other.
Views
Replies
Total Likes
You can debug or add logs to see if the Util method gives the expected output.
Views
Replies
Total Likes
HI @narendiran100, issue finally found not in the AEM, that need to check in the front-end code