LiveTable query parameters

It is a livetable with a custom JSON.

In the JSON I can use $displayField=$doc.display(“FieldName”) or $DisplayField =$object.getProperty(“FieldName”).value

I think I need to encode $DisplayField as HTML

When I change OutputSyntax=HTML in the link of the JSON below, I see the HTML code.

?xpage=plain&outputSyntax=plain&mainObjId=DSET_j8AWqZzY5IoLW

If I leave it to plain, the HTML is not encoded.

I am close, but do not understand why it is not working.

When using display and then $escapetool.html(String) I get the HTML. However it doesn’t show in the JSON, only in the WIKI page.

in the JSON:

##loop through results

#set($docOmschrijving=$objitem.getProperty("omschrijving").value)

##If changed to below I do get HTML output in WIKI page but $docOmschrijving returns "" in the JSON.
##set($docOmschrijving=$docitem.display("omschrijving"))
##set($docOmschrijving=$escapetool.html($docOmschrijving))

##Line below adds a row to the json.
#set($discard=$json.rows.add({
  "doc_viewable" : true,
  "doc_url" : "$docURL",
  "doc_edit_url" : "$docEditURL",
  "doc_delete_url" :"$docDeleteURL",
  "afkorting" : "$docAfkorting",
  "naam" : "$docNaam",
  "omschrijving" :"$docOmschrijving",
}))

#end
##output the json:

$jsontool.serialize($json)

This is not correct. You’re supposed to output valid JSON but you’re outputting HTML. So you need to escape it.

Now, as I mentioned, when you use the #livetable macro you need to configure the column containing HTML to display HTML. See https://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable+Macro#HParameter24columnsProperties

Hi Vincent,

I have configured the livetable macro to output HTML. That part is working correctly.

I just don’t seem to get the right code to escape the HTML

I tried the code that I commented out:

#set($docOmschrijving=$docitem.display(“omschrijving”))
#set($docOmschrijving=$escapetool.html($docOmschrijving))

I also tried to $espacetool.json($docOmschrijving) and $escapetool.json($espacetool.html($docOmschrijving))