Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

How to remove p tags from contentfragment multiline text using java

Avatar

Level 2

I have a content fragment with multiline text field as one of the element in it. When I give any description in that, it is storing inside <p> tag and &nbsp(for blank spaces). I want to store this contentElement as a json alogng with other content fragment elements.

How can i pass this multiline text to backend java ignoring these <p> and &nbsp tags. Below is screenshot of how the multiline text is getting saved in CRX. Need help on this

 

parthibanselvam_0-1653769550327.png

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @MayurSatav @parthibanselvam 

From the above article removeSingleParagraphContainer attribute was for the Classic UI and deprecated.

As per my understanding, there isn’t anything OOTB available that can remove the p single paragraph container tag, to achieve this, one can deal with Sling Model.

Perfect Reference: https://sourcedcode.com/blog/aem/aem-richtext-remove-p-tag-removesingleparagraphcontainer-for-touch-...

Regards,
Santosh

View solution in original post

3 Replies

Avatar

Community Advisor

Hi @parthibanselvam 

 

Why do you want to store data in JSON format? If your intention is to expose data in JSON format eventually - that is OOTB. 

Have a look at below few links

1. https://experienceleague.adobe.com/docs/experience-manager-learn/sites/content-fragments/content-fra...

2. https://m.youtube.com/watch?v=al7k9c81lTM

3. https://www.aemtutorial.info/2017/06/aem-content-fragment-output-as-json.html?m=1

 

However, if you still wants to customize it you can do it by extending content fragments for more details please visit this article 

https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/customizing-c...

Similar requirement: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/p-tag-removal-from-text-co...

 

Hope that helps you!

 

Regards,

Santosh

 

 

Avatar

Correct answer by
Community Advisor

Hi @MayurSatav @parthibanselvam 

From the above article removeSingleParagraphContainer attribute was for the Classic UI and deprecated.

As per my understanding, there isn’t anything OOTB available that can remove the p single paragraph container tag, to achieve this, one can deal with Sling Model.

Perfect Reference: https://sourcedcode.com/blog/aem/aem-richtext-remove-p-tag-removesingleparagraphcontainer-for-touch-...

Regards,
Santosh