<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to call freemarker function with param from javascript in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/how-to-call-freemarker-function-with-param-from-javascript/m-p/237310#M190440</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;THANKS Mike….&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;saves my time&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(Only to tell you thanks… i have created account in alfresco &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://connect.hyland.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 16 Mar 2013 08:35:55 GMT</pubDate>
    <dc:creator>manan</dc:creator>
    <dc:date>2013-03-16T08:35:55Z</dc:date>
    <item>
      <title>How to call freemarker function with param from javascript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-call-freemarker-function-with-param-from-javascript/m-p/237304#M190434</link>
      <description>Hi, I am calling a FreeMarker function from Javascript function. function foo(param1,param2){ validation ……… txt = "${report("${param1!'NA'}",param2)}"; document.write(txt);}&amp;nbsp; &amp;lt;#function report paramX paramY&amp;gt;&amp;nbsp; &amp;lt;#assign txt=""&amp;gt;&amp;lt;#assign txt=txt+paramX&amp;gt; MY CODE ……………………….&amp;nbsp; &amp;lt;#return</description>
      <pubDate>Mon, 01 Feb 2010 11:32:32 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-call-freemarker-function-with-param-from-javascript/m-p/237304#M190434</guid>
      <dc:creator>rptapas</dc:creator>
      <dc:date>2010-02-01T11:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to call freemarker function with param from javascript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-call-freemarker-function-with-param-from-javascript/m-p/237305#M190435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you tried removing the quotes from around "param1" ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Feb 2010 12:54:33 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-call-freemarker-function-with-param-from-javascript/m-p/237305#M190435</guid>
      <dc:creator>mikeh</dc:creator>
      <dc:date>2010-02-01T12:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to call freemarker function with param from javascript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-call-freemarker-function-with-param-from-javascript/m-p/237306#M190436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes I did. Does not work. In fact param1 is outside quotes. I tried to concatenate the string using +param1+. Even this does not work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Feb 2010 10:24:27 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-call-freemarker-function-with-param-from-javascript/m-p/237306#M190436</guid>
      <dc:creator>rptapas</dc:creator>
      <dc:date>2010-02-02T10:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to call freemarker function with param from javascript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-call-freemarker-function-with-param-from-javascript/m-p/237307#M190437</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Looking at this again, I'm not really sure what you're trying to achieve - I think you might misunderstand how the page gets rendered.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On the server, Freemarker will get the template and try to render &lt;/SPAN&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;function foo(param1, param2)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; txt = "${report(param1!'NA', param2)}";&lt;BR /&gt;&amp;nbsp;&amp;nbsp; document.write(txt);&lt;BR /&gt;}&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;In doing so, it will call the "report" function with param1 and param2. The mark-up tells Freemarker to replace param1 with "NA" if param1 isn't defined. If this is all your code, then param1 won't be defined and you'll get "NA". Same for param2, but in this case you'll get a Freemarker exception if you ever try to access param2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&amp;lt;#function report paramX paramY&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;#assign txt=""&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;#assign txt=txt+paramX&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;#return txt&amp;gt;&lt;BR /&gt;&amp;lt;/#function&amp;gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Freemarker calls the "report" function with "NA" and a missing second parameter. Your function returns "NA".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The resultant template is therefore:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;function foo(param1, param2)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; txt = "NA";&lt;BR /&gt;&amp;nbsp;&amp;nbsp; document.write(txt);&lt;BR /&gt;}&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt;which is returned to the client. The client (web browser) then runs the JavaScript (presumably via some other code you've not posted) and the "NA" string gets output.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There's no way for the *client side* web browser code to call a *server side* Freemarker function, which is what I think you're assuming will happen?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Feb 2010 12:01:50 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-call-freemarker-function-with-param-from-javascript/m-p/237307#M190437</guid>
      <dc:creator>mikeh</dc:creator>
      <dc:date>2010-02-02T12:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to call freemarker function with param from javascript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-call-freemarker-function-with-param-from-javascript/m-p/237308#M190438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mike,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; thank you for the reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Well the complete code is written in a single .ftl file. Where there is a form (html), on clicking the button, the javascript function is called which validates param1 and param2, if both the values satisfy the required conditions, then the FreeMarker function (which is written in the same .ftl file) is called. If I access param1 and param2 in the function, I get "param1" and "param2" as it is and not the VALUE of variables "param1" and "param2".&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; That is my issue.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; Alternatively is there any other way to achieve the required functionality:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; There is a form (html), on clicking the button, a javascript function is called, which validates param1 and param2. If both the values satisfy the required conditions, then the FreeMarker function (which is written in the same .ftl file) is called.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; These two values, are conditions, example the created date and modified date of an event, in a work flow. Based on these dates, I want to generate a report which will display all the events which satisfy the given conditions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; Thank you, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Praveen&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Feb 2010 03:56:47 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-call-freemarker-function-with-param-from-javascript/m-p/237308#M190438</guid>
      <dc:creator>rptapas</dc:creator>
      <dc:date>2010-02-03T03:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to call freemarker function with param from javascript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-call-freemarker-function-with-param-from-javascript/m-p/237309#M190439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm afraid you're still not quite understanding.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You &lt;/SPAN&gt;&lt;STRONG&gt;cannot&lt;/STRONG&gt;&lt;SPAN&gt; call Freemarker code from JavaScript in a web browser. Freemarker renders the HTML on the server - think of as PHP if you're more used to that. Once the HTML has been generated, Freemarker has *no further involvement* in the page. You can verify this yourself by viewing the HTML source from the browser - all the Freemarker code has been rendered as HTML.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can use JavaScript validation functions before you POST the form back to the server, but in order for Freemarker to "see" the data from the form, you'd need to write a new webscript.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Feb 2010 09:28:27 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-call-freemarker-function-with-param-from-javascript/m-p/237309#M190439</guid>
      <dc:creator>mikeh</dc:creator>
      <dc:date>2010-02-03T09:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to call freemarker function with param from javascript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-call-freemarker-function-with-param-from-javascript/m-p/237310#M190440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;THANKS Mike….&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;saves my time&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(Only to tell you thanks… i have created account in alfresco &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://connect.hyland.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Mar 2013 08:35:55 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-call-freemarker-function-with-param-from-javascript/m-p/237310#M190440</guid>
      <dc:creator>manan</dc:creator>
      <dc:date>2013-03-16T08:35:55Z</dc:date>
    </item>
  </channel>
</rss>

