Xpages - have you ever had to generate HTML from your java code? Gagawa java library has amazing fluent API to help you avoid string concatenation

David Marko  1 July 2013 10:21:52
Have you ever had to create HTML in your JAVA code for some purpose?  Maybe you have used something like this:  "<div class='"+divName+"'>"+"<a href='"+url+"'">" ... got lost in lot of texts, quotes and  finally you missed to close some div tag :-) If you are working like this, Gagawa library can simplify your code a lot. Look at the code below ... I guess you can read and understand the code without knowing the gagawa itself. Gagawa fluent API is extremely nice!

Image:Xpages - have you ever had to generate HTML from your java code? Gagawa java library has amazing fluent API to help you avoid string concatenation

What's more ... it works nice with Xpages without permissions issues as some libs conflict with Domino. If you are interested in ... look at here  https://code.google.com/p/gagawa/  and you can even find some examples here https://code.google.com/p/gagawa/source/browse/trunk/gagawa/examples/com/hp/gagawa/examples/


Comments

1Stephan H. Wissel  02.07.2013 2:42:48  Xpages - have you ever had to generate HTML from your java code? Gagawa java library has amazing fluent API to help you avoid string concatenation

Nice one. I was using Mustache {{mustache}} for some of the HTML generation. The approach is very different, but also efficient. You keep your HTML somewhere (file resources, attachments etc.) and have placeholders with double curly brackets (hence the name mustache) where your values go. Then you pass a Java object and the template to the mustache processor and you get the resulting stuff (can be HTML, XML, plain text). Available on github in tons of languages

2David Marko  02.07.2013 7:46:58  Xpages - have you ever had to generate HTML from your java code? Gagawa java library has amazing fluent API to help you avoid string concatenation

I have used the Apache Velocity this way as a template engine. Its quite nice ...

TOPlist