Get af:richTextEditor value without HTML formatting and tags using jsoup library

Sharing is Caring

af:richTextEditor (In this post, I’ll show you how to Get af:richTextEditor value as plain text.)

is used to format text in rich text using HTML formatting and it is used to get the formatted text. Previously I have posted about it Cool Component – Using richTextEditor as text editor, HTML editor with custom toolbox in Oracle ADF

But I have seen developers asking about getting the plain text value from richTextEditor,
It means on UI editor shows HTML formatted text but when getting value in managed bean it should ignore HTML tags and formatting
This component is designed for rich text editing so there is no direct way to get plain text
So for this requirement, we need to parse HTML into plain text, Here I am using jsoup java library to parse HTML

Get af:richTextEditor value

When we get this value in bean using component binding it returns

Now to get the plain text without formatting just parse this HTML using the jsoup library, Add library to the viewController project

and use this simple code

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

Document doc = Jsoup.parse(ritValue);
System.out.println(doc.text());

and it returns

Cheers 🙂 Happy Learning

Related Posts

I’m an Oracle ACE, Blogger, Reviewer,
Technical Lead working on Oracle ADF

3 thoughts on “Get af:richTextEditor value without HTML formatting and tags using jsoup library”

Leave a Reply

Your email address will not be published. Required fields are marked *