{"id":1375,"date":"2008-09-17T03:45:36","date_gmt":"2008-09-17T08:45:36","guid":{"rendered":"http:\/\/www.mrc-productivity.com\/legacy\/?page_id=1375"},"modified":"2011-12-22T15:11:59","modified_gmt":"2011-12-22T21:11:59","slug":"numeric-functions-within-freemarker","status":"publish","type":"page","link":"https:\/\/www.mrc-productivity.com\/legacy\/freemarker\/numeric-functions-within-freemarker","title":{"rendered":"Numeric Functions within Freemarker"},"content":{"rendered":"<p><!-- Begin Content --><\/p>\n<h1>Numeric Functions Available within Freemarker<\/h1>\n<p>&nbsp;<\/p>\n<p>There are times when you may wish to control the output format of a numeric field within your Java Servlet Applications.  Freemarker allows you to do this easily directly within the m-Painter environment.  To add these functions, simply open m-Painter and right click on the Field you wish to modify.  Select the &quot;Application Field Properties&quot; option.  Add the Numeric Function into the &quot;Representation&quot; box in the correct location.  When completed, hit OK.  Then be sure to save your application.<\/p>\n<p>One of the most useful options available to Numeric Fields within Freemarker is the ability to apply formatting directly within the source of the HTML.<\/p>\n<p><strong>Modifying into a String<\/strong><\/p>\n<p>The use of the &quot;?string&quot; option is vital.  Numeric values such as 1000000 are easy for a computer to understand, but difficult for a human because the zeros run together.  However, written like 1,000,000 is very easy for a human to read.  Similarly, if a value is smaller than 1E-16 (a number with more than 16 positions to the right of the decimal place) it would be rounded to zero, whereas a string function would display the true value.  Converting this value to a string allows the JVM installed to control the look of the value based upon the location.  European JVMs could render a value formatting slightly different than a US JVM due to the location.<\/p>\n<p>As an example, let&#39;s say that I have a field with a value equal to 1234.  If no Edit Code is selected within m-Power, my output will look like this:<\/p>\n<p><img decoding=\"async\" src=\"\/legacy\/images\/freemarkernumbers1.jpg\" \/><\/p>\n<p>Next, I will illustrate the two most popular Freemarker Formatting options: Number &amp; Currency:<\/p>\n<p>My normal field substitution looks like this:<\/p>\n<p><code>${row.OTHERSS?html}<\/code> &#8212; This outputs the text 1234 (This is the default code generated by m-Power).<\/p>\n<p><code>${row.OTHERSS_o?string.number}<\/code> &#8212; This outputs the text 1,234.<\/p>\n<p><code>${row.OTHERSS_o?string.currency}<\/code> &#8212; This outputs the text $1,234.00.<\/p>\n<p><img decoding=\"async\" src=\"\/legacy\/images\/freemarkernumbers2.jpg\" \/><\/p>\n<p><strong>_o<\/strong> &#8212; This specifies to Freemarker that this is a numeric field, capable of allowing string manipulation.<\/p>\n<p><strong>string.number<\/strong> &#8212; This specifies to treat this field like a normal, numeric field (Using commas and periods where necessary).<\/p>\n<p><strong>string.currency<\/strong> &#8212; This specifies to treat this field to display like money (The use of $, commas and period where necessary).<\/p>\n<p><strong>Note:<\/strong> If you are located outside of the US, your string.number and string.currency will display differently as your JVM is written specifically for your country&#39;s standards.<\/p>\n<p><strong>Note:<\/strong> Freemarker Formatting codes will take precedence over m-Power Edit Codes.<\/p>\n<p>To learn even more Advanced Formatting for Numeric Fields, click <a href=\"https:\/\/www.mrc-productivity.com\/legacy\/freemarker\/html-edit-codes-to-control-data-rounding\">here<\/a>.<\/p>\n<p><!-- End Content --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Numeric Functions Available within Freemarker &nbsp; There are times when you may wish to control the output format of a numeric field within your Java Servlet Applications. Freemarker allows you to do this easily directly within the m-Painter environment. To add these functions, simply open m-Painter and right click on the Field you wish to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1352,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1375","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages\/1375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/comments?post=1375"}],"version-history":[{"count":3,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages\/1375\/revisions"}],"predecessor-version":[{"id":8354,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages\/1375\/revisions\/8354"}],"up":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages\/1352"}],"wp:attachment":[{"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/media?parent=1375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}