I recently implemented a comments section that used Textile formatting
like in confluence. In fact it uses the ConfluenceDialect. I really
liked how it turned out. Of course there is some end user training
about wiki/textile markup rather than HTML. I need to look at
Confluence and see what rich text editor they use, since you can do
both.
Let the users type in the markup .... *bold* , h1. heading 1, etc and
then use this static method to output the HTML when viewing the entry:
public static String formatTextileStringtoHtml(String source){
StringWriter writer = new StringWriter();
HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer);
builder.setEmitAsDocument(false);
TextileParser parser = new TextileParser();
parser.setBuilder(builder);
parser.setDialect(new ConfluenceDialect());
parser.parse(source);
return writer.toString();
}
-D
On Apr 22, 2008, at 6:05 AM, Martin Homik wrote:
I am writing a simple blog application. Each entry has a title and a
body.
The body may contain html elements such as "<p>". However, if you
add the
following value into your sample data, the html elements are cut off
and
hence not inserted into the database:
<value> <p> London is a great city. </p></value>
The solution is to xml-escape the html elements:
<value> &lt;p&gt; London is a great city.
&lt;/p&gt;</value>
If you look into your database, then you'll see that the value
<p> London is a great city. </p>
was inserted. Hope that helps other newbies like me. I searched for
some
hints in the forum, but could not find.
By the way, if you use Struts2 and if you want to output the html
snippet
with formatting, then you have to disable escaping. In my case it
looks like
this:
<s:property escape="false" value="body"/>
Cheers.
--
View this message in context:
http://www.nabble.com/How-to-add-html-values-in-sample-data-tp16824092s2369p16824092.html
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]