javascript - Rendering Spring ModelAndView Object with Thymeleaf -


i have controller :

    @autowired     servletcontext servletcontext;      public modelandview handlelogin(locale locale, model viewmodel, httpservletrequest request)                     throws exception {             [...]             modelandview scheduler = new modelandview("scheduler");             scheduler.addobject("body", schedulercreator.getscheduler().render());              return scheduler;     } 

the render() function returns string html/css/javascript, should place on page html.

i attempted placing in thymeleaf template :

    <html xmlns:th="http://www.thymeleaf.org">       <head th:include="layout :: htmlhead" th:with="title='doctorscheduler'"></head>       <body>         <div th:replace="layout :: navbar">(navbar)</div>         <div th:text="${body}" id="scheduler"></div>         <div th:include="layout :: footer" id="footer">(footer)</div>       </body>     </html> 

on the screen, header , footer displayed scheduler, html code displayed , not rendered :

    <script src="/javaplanner/dhtmlxscheduler.js" type="text/javascript" charset="utf-8"></script> <script src="/javaplanner/ext/dhtmlxscheduler_url.js" type="text/javascript" charset="utf-8"></script> <script src="/javaplanner/ext/dhtmlxscheduler_pdf.js" type="text/javascript" charset="utf-8"></script> <link rel="stylesheet" href="/javaplanner/dhtmlxscheduler.css" type="text/css" charset="utf-8"> <div id='scheduler_here' class='dhx_cal_container' style='width:900px;height:100%;'> <div class='dhx_cal_navline'> <div class='dhx_cal_export pdf' id='export_pdf' title='export pdf' onclick='scheduler.topdf("http://dhtmlxscheduler.appspot.com/export/pdf", "color")'> </div> <div class='dhx_cal_prev_button'> </div> <div class='dhx_cal_next_button'> </div> <div class='dhx_cal_today_button'></div> <div class='dhx_cal_date'></div> <div class='dhx_cal_tab' name='month_tab' style='left:76px;'></div> <div class='dhx_cal_tab' name='week_tab' style='left:140px;'></div> <div class='dhx_cal_tab' name='day_tab' style='left:204px;'></div> </div> <div class='dhx_cal_header'></div> <div class='dhx_cal_data'></div> </div> <script> scheduler.config.serverlists = {}; scheduler.locale.labels.section_time = 'when'; scheduler.locale.labels.section_appointmentname = 'description'; scheduler.locale.labels.section_patientid = 'patient id'; scheduler.locale.labels.section_appointfor = 'appoint for'; scheduler.locale.labels.section_staffid = 'staff id'; scheduler.locale.labels.section_assistantid = 'assistant id'; scheduler.locale.labels.section_departmentwardid = 'dept. ward id'; scheduler.locale.labels.section_appointmentstatusid = 'appt. status id'; scheduler.locale.labels.section_referenceconsultancyid = 'ref. consult. id'; scheduler.locale.labels.section_nextappointmentid = 'next. appt. id'; scheduler.locale.labels.section_consultancyid = 'consultancy id'; scheduler.locale.labels.section_firmcode = 'firm code'; scheduler.config.lightbox.sections = [ {"name":"time", "type":"time", "map_to":"auto"}, {"height":40, "name":"appointmentname", "type":"textarea", "map_to":"appointmentname"}, {"name":"patientid", "type":"select", "map_to":"patientid", "options":scheduler.serverlist("patientslookup")}, {"name":"appointfor", "type":"select", "map_to":"appointfor", "options":scheduler.serverlist("appointforlookup")}, {"name":"staffid", "type":"select", "map_to":"staffid", "options":scheduler.serverlist("stafflookup")}, {"name":"assistantid", "type":"select", "map_to":"assistantid", "options":scheduler.serverlist("assistantslookup")}, {"name":"departmentwardid", "type":"select", "map_to":"departmentwardid", "options":scheduler.serverlist("wardlookup")}, {"name":"appointmentstatusid", "type":"select", "map_to":"appointmentstatusid", "options":scheduler.serverlist("apptstatuslookup")}, {"name":"referenceconsultancyid", "type":"select", "map_to":"referenceconsultancyid", "options":scheduler.serverlist("refconslookup")}, {"name":"nextappointmentid", "type":"select", "map_to":"nextappointmentid", "options":scheduler.serverlist("nextapptlookup")}, {"name":"consultancyid", "type":"select", "map_to":"consultancyid", "options":scheduler.serverlist("consultantslookup")}, {"height":40, "name":"firmcode", "type":"textarea", "map_to":"firmcode"} ]; scheduler.config.details_on_dblclick = true; scheduler.config.dblclick_create = true; scheduler.config.scroll_hour = 8; scheduler.config.skin = 'terrace'; scheduler.config.details_on_create = true; scheduler.templates.lightbox_header = function(start,end,ev){ var temp = "";temp += "<strong>appointment</strong>"; return temp; }; scheduler.init('scheduler_here',new date(2014, 8, 10, 15, 55, 33)); scheduler.config.prevent_cache = true; scheduler.load("appointment", "json"); var dp = new dataprocessor("appointment"); dp.init(scheduler); dp.settransactionmode("post", false);</script> 

what's wrong ? how place html/css/javascript string within thymeleaf template rendered ? thymeleaf tag may ignore ? other method/approach ? input welcome, thank !

you cannot use th:text display pre-rendered html code. instead, need unescaped text attribute th:utext

see section in documentation more details: http://www.thymeleaf.org/doc/usingthymeleaf.html#unescaped-text


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -