<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
code
{mso-style-priority:99;
font-family:"Courier New";}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
span.gmail-apple-tab-span
{mso-style-name:gmail-apple-tab-span;}
span.E-MailFormatvorlage19
{mso-style-type:personal-reply;
font-family:"Arial",sans-serif;
color:#1F497D;
font-weight:normal;
font-style:normal;
text-decoration:none none;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="DE" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D;mso-fareast-language:EN-US">This is the normal behavior… javascript is „removed“ when the edited content is replaced.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D;mso-fareast-language:EN-US">You can use
</span><span lang="EN-GB" style="font-size:10.0pt;font-family:"Courier New"">enableReload<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><a href="http://documentation.opencms.org/opencms-documentation/typical-tasks/writing-jsps/interesting-el-expressions/">http://documentation.opencms.org/opencms-documentation/typical-tasks/writing-jsps/interesting-el-expressions/</a><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:36.0pt">
<span lang="EN-GB">Placing </span><span lang="EN-GB" style="font-size:10.0pt;font-family:"Courier New"">${cms.enableReload}</span><span lang="EN-GB"> somewhere in your formatter will result in an automatically page reload when content is edited (or moved to
a different container).<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Von:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> opencms-dev-bounces@opencms.org [mailto:opencms-dev-bounces@opencms.org]
<b>Im Auftrag von </b>Clement Wee<br>
<b>Gesendet:</b> Freitag, 24. Februar 2017 11:06<br>
<b>An:</b> opencms-dev@opencms.org<br>
<b>Betreff:</b> Re: [opencms-dev] javascript in resource-type fails to run after property edit and save from workspace<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">The relevant formatter jsp is:<o:p></o:p></p>
<div>
<p class="MsoNormal"><%@page buffer="none" session="false" trimDirectiveWhitespaces="true"%><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><%@ taglib prefix="cms" uri="<a href="http://www.opencms.org/taglib/cms">http://www.opencms.org/taglib/cms</a>"%><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><%@ taglib prefix="c" uri="<a href="http://java.sun.com/jsp/jstl/core">http://java.sun.com/jsp/jstl/core</a>"%><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><%@ taglib prefix="fmt" uri="<a href="http://java.sun.com/jsp/jstl/fmt">http://java.sun.com/jsp/jstl/fmt</a>"%><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><%@ taglib prefix="fn" uri="<a href="http://java.sun.com/jsp/jstl/functions">http://java.sun.com/jsp/jstl/functions</a>"%><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><cms:formatter var="content"><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><c:set var="svg" value="image-${<a href="http://cms.element.id">cms.element.id</a>}"/><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span"> </span><div class="margin-bottom-30"><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span"> </span>
<div class="panel"><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span">
</span><h3>${<a href="http://cms.element.id">cms.element.id</a>}</h3><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span"> </span>
</div><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span"> </span>
<div class="image" id="${svg}"><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span">
</span><!--<svg width="400" height="110"><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <span class="gmail-apple-tab-span">
</span><rect width="300" height="100" style="fill:${content.value.BGColor};stroke-width:3;stroke:rgb(0,0,0)"><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <span class="gmail-apple-tab-span">
</span>Sorry, your browser does not support inline SVG. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span">
</span></rect><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span">
</span></svg>--><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span"> </span>
</div><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span"> </span>
<script><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span">
</span>var svg = d3.select("#${svg}").append("svg").attr({"width":"400", "height":"110"});<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span">
</span>var rectStyle = "fill:${content.value.BGColor};stroke-width:3;stroke:rgb(0,0,0)";<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span">
</span>var rect = <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span">
</span>svg.append("rect")<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span">
</span>.attr("width", 300)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span">
</span>.attr("height", 100)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span">
</span>.attr("style", rectStyle);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span"> </span>
</script><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-apple-tab-span"> </span></div><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"></cms:formatter><o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Fri, Feb 24, 2017 at 6:00 PM, Clement Wee <<a href="mailto:clement@elixirtech.com" target="_blank">clement@elixirtech.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<p class="MsoNormal">Hi OpenCMS Admin,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">I am a new user of OpenCMS who is developing a module for a client who uses OpenCMS.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I have deisgned a simple resource-type to test out D3.JS library.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I coded in an inline script within the resource-type JSP itself, because I don't know whether EL is supported in Head Includes Inline javascript.<br>
<br>
When I first load a page with an element instance of the module, the SVG created using D3 shows up, but once I edit the properties of that element via the pencil-edit and save, the SVG disappears, only showing up again when I refresh the page.<br>
<br>
Can you help me resolve this issue?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Regards,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Clement Wee<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Singapore<o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>