{"id":1375,"date":"2008-09-17T03:45:36","date_gmt":"2008-09-17T08:45:36","guid":{"rendered":"http:\/\/www.mrc-productivity.com\/docs\/?page_id=1375"},"modified":"2021-09-30T11:07:31","modified_gmt":"2021-09-30T16:07:31","slug":"numeric-functions-within-freemarker","status":"publish","type":"ht_kb","link":"https:\/\/www.mrc-productivity.com\/docs\/knowledge-base\/numeric-functions-within-freemarker","title":{"rendered":"Numeric Functions within Freemarker"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Overview<\/h3>\n\n\n\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 &#8220;Application Field Properties&#8221; option. Add the Numeric Function into the &#8220;Representation&#8221; box in the correct location. When completed, hit OK. Then be sure to save your application.<\/p>\n\n\n\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\n\n\n<h3 class=\"wp-block-heading\"><strong>Modifying into a String<\/strong><\/h3>\n\n\n\n<p>The use of the &#8220;?string&#8221; 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\n\n\n<p>As an example, let&#8217;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\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/docs\/vue-images\/freemarkernumbers1.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>Next, I will illustrate the two most popular Freemarker Formatting options: Number &amp; Currency:<\/p>\n\n\n\n<p>My normal field substitution looks like this:<\/p>\n\n\n\n<p><code>${row.OTHERSS?html}<\/code> &#8212; This outputs the text 1234 (This is the default code generated by m-Power).<\/p>\n\n\n\n<p><code>${row.OTHERSS_o?string.number}<\/code> &#8212; This outputs the text 1,234.<\/p>\n\n\n\n<p><code>${row.OTHERSS_o?string.currency}<\/code> &#8212; This outputs the text $1,234.00.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/docs\/vue-images\/freemarkernumbers2.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>_o<\/strong> &#8212; This specifies to Freemarker that this is a numeric field, capable of allowing string manipulation.<\/p>\n\n\n\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\n\n\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\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-alert\">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&#8217;s standards.<\/p>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-info\">Freemarker Formatting codes will take precedence over m-Power Edit Codes.<\/p>\n\n\n\n<p>To learn even more Advanced Formatting for Numeric Fields, click <a href=\"https:\/\/www.mrc-productivity.com\/docs\/freemarker\/html-edit-codes-to-control-data-rounding\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview 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&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[265],"ht-kb-tag":[],"class_list":["post-1375","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-freemarker"],"_links":{"self":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/1375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/comments?post=1375"}],"version-history":[{"count":4,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/1375\/revisions"}],"predecessor-version":[{"id":11101,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/1375\/revisions\/11101"}],"wp:attachment":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/media?parent=1375"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb-category?post=1375"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb-tag?post=1375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}