java - How to format json in wicket dataview using javascript -


i trying display json data in wicket dataview. if want display json indentation, how can achieve using java script?

i find many sources pretty format json using java script. how can call function javascript inside dataview populateitem method format json described in link http://jsfiddle.net/unlsj/

html

<table>    <tr>       <th>name</th>       <th>value</th>    </tr>    <tr wicket:id="notificationdetails">       <td valign="top"><span  wicket:id="name"></span></td>       <td valign="top"><span  wicket:id="value"></span></td>    </tr> </table> 

my java:

    dataview = new listview<datafortable>("notificationdetails",datafortablelist)  {   private static final long serialversionuid = 1l;    @override   protected void populateitem(final listitem<datafortable> item)    {     item.setdefaultmodel(new compoundpropertymodel<datafortable>(item.getmodel()));     item.add(new label("name"));     item.add(new label("value"));   } }; 

i have tried use jackson object mapper format json before adding label, not help. wicket page displays this

mapper.defaultprettyprintingwriter().writevalueasstring(value); 

the wicket page displays this

 {\r\n \"action\" : \"add\",\r\n \"schedule\"...  

can please resolve issue?

you should use multilinelabel instead of label \n replaced <br/>. can replace \t &nbsp; or other space character. in case use multilinelabel#setescapemodelstrings(false).


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -