Document generation in Mendix

0
Hi, I am trying to generate a HTML document which only has a String, but that string is created as a html file with the corresponding tags. Unfortunately, the file is being generated with &lt; and &gt; instead of < and >. This makes the browser not recognize the tags and displays it as a string instead of a table as I’m meaning to. The solution to change everything into a document template with a table is not one I would choose because the functionality would need a lot of refactoring.  Here is a sample: &lt;tr&gt; &lt;th  style="padding: 5px"&gt;Categorie&lt;/th&gt; &lt;th  style="padding: 5px"&gt;Vraag&lt;/th&gt;   vs what I need it to look like: <tr> <th  style="padding: 5px">Categorie</th> <th  style="padding: 5px">Vraag</th>   Does anybody know how to make it generate with the tags instead of the &lt; and &gt; ? Thanks, Razvan    
asked
2 answers
1

Sounds like you want to use HTML Decoding. Luckily, this is really easy in Mendix!

Download the CommunityCommons module from the appstore, if you haven’t done so already. (IMO this is a go-to for any app you make, but that’s just a side note).

Once that’s in your app, you can use the “Call Java Action” in a microflow. Select the Java Action “HtmlToPlainText”, and use your &lt;tr&gt;
&lt;th  style="padding: 5px"&gt;Categorie&lt;/th&gt;
&lt;th  style="padding: 5px"&gt;Vraag&lt;/th&gt; 
as the input parameter. It should output with your tags, and any other decoded HTML you had in there, to be used in the rest of the flow.

 

Hope this helps!

answered
0

Luke, I think that that java action uses javax.swing.text.html.HTMLEditorKit to convert the arg to plain text, so you’re going to loose all the tags. Try implement commons/lang3/StringEscapeUtils, it has what your after

answered