[jira] Commented: (OFBIZ-203) Freemarker postal address formatter macro

Posted by Nicolas Malin (Jira) on
URL: http://ofbiz.116.s1.nabble.com/jira-Created-OFBIZ-203-Freemarker-postal-address-formatter-macro-tp171329p171332.html

    [ http://issues.apache.org/jira/browse/OFBIZ-203?page=comments#action_12435163 ]
           
Si Chen commented on OFBIZ-203:
-------------------------------

I thought about this further and think these are the issues:

1.  We have FTL/HTML code all over the place for postal addresses, and they're starting to diverge and become a mess.  Some use the Geo.abbreviationName, some use Geo._geoId.  Some are for US formats, some are for European formats.  It would be nicer to standardize them all.

2.  David's suggestion of using screen widget + FTL is simpler than the FTL transform macro of Leon's, and at first I thought it was the better idea.  However, it suffers from two issues.  One is that screen widget requires more overhead, and on a page with lots of addresses, it could become a perform problem.  The second issue is that we need postal addresses for HTML, XSL:FO, and plain text, plus all the different national formats, it could end up being a lot of little FTL files.

3.  Of course, using a transform like <@ofbizPostalAddress> does make it less modifiable, in the same way that <@ofbizCurrency> makes it less modifiable should you want to change or using the form-widget makes it less flexible to change the format of a form.  The reverse is that these tools make writing postal addresses, currency numbers, or forms more efficient, standardized, and streamlined.  (The same can be said of the icu4j library for currencies and Java DateFormat class)  After some thinking, I feel that postal addresses is a pretty standardized thing, perhaps a little less so than currencies or dates, but definitely more so than say an html form.  So I personally feel that it is better to have a standard transform than to have different html/ftl code on every page.

4.  The syntax at this point looks like this:
<@ofbizPostalAddress address=[postal address GenericEntity or Map] format="text|html" inline="true|false" delimiter=";"/>

so you can pass in a GenericEntity or Map, format it as plain text or html, compress it on one line or on separate lines, and if on one line, specifies a separator.

Please give us your feedback on the syntax for using this transform.

5.  I agree with David and Jacopo that this transform belongs in party instead of in framework.

Please give us your thoughts on this--even if you don't like it!!

> Freemarker postal address formatter macro
> -----------------------------------------
>
>                 Key: OFBIZ-203
>                 URL: http://issues.apache.org/jira/browse/OFBIZ-203
>             Project: OFBiz (The Open for Business Project)
>          Issue Type: New Feature
>          Components: framework
>    Affects Versions: SVN trunk
>            Reporter: Leon Torres
>            Priority: Minor
>         Attachments: ofbizPostalAddress.patch, test.bsh, test.ftl
>
>
> Define a macro <@ofbizPostalAddress address=inputMapOrGenericValue/>  to format postal addresses in a consistent, flexible way with attention to country postal formats.  The output should support both HTML and Text formats.  It should be easily extensible, with future XSL:Fo support in mind.
> I created an implementation as an exercise to learn the freemarker template system.  It was designed with future macros in mind.  Currently implemented are rules for generating US, German and Royal Mail format postal addresses.  (The address country determines the format.)  Also provided are test.bsh and test.ftl so people may try them out.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira