Quantcast
Channel: Ashish Awasthi's Blog
Viewing all articles
Browse latest Browse all 165

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

$
0
0


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



But I have seen developers asking about getting 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

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


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


and use this simple code

importorg.jsoup.Jsoup;
importorg.jsoup.nodes.Document;

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

and it returns

Cheers :) Happy Learning

Viewing all articles
Browse latest Browse all 165

Trending Articles