Text formatting not working:
Solved! Go to Solution.
Views
Replies
Total Likes
HI @narendiran_ravi, issue finally found not in the AEM, that need to check in the front-end code
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...
Handled correctly only but formatting not works:
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!";
}
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?
Hey, sorry nope, your own custom solution is required.
When you say it is not working. Could you elaborate that a little ?
For example, the formatting is applied to the text field which is working fine in 1 component but not working for the other.
You can debug or add logs to see if the Util method gives the expected output.
HI @narendiran_ravi, issue finally found not in the AEM, that need to check in the front-end code