[ 
https://issues.apache.org/jira/browse/OFBIZ-203?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13031526#comment-13031526
 ] 

Adrian Crum commented on OFBIZ-203:
-----------------------------------

If I was designing something like this I would follow the pattern in the 
current Java formatting classes: Create a PostalAddressFormat class that takes 
a formatting string or a Locale object. Pre-defined formatting strings could be 
kept in locale-specific properties files - like the UI labels. The 
PostalAddressFormat class would take the supplied Locale, look up the 
formatting string, and format the address. Simple and extensible.

PostalAddressFormat paf = PostalAddressFormat.getInstance(someLocale);
String formattedAddress = paf.parse(somePostalAddress);

The formattedAddress String could be converted to HTML or whatever.


> Freemarker postal address formatter macro
> -----------------------------------------
>
>                 Key: OFBIZ-203
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-203
>             Project: OFBiz
>          Issue Type: New Feature
>          Components: framework
>    Affects Versions: SVN trunk
>            Reporter: Leon Torres
>            Assignee: Jacques Le Roux
>            Priority: Minor
>             Fix For: SVN trunk
>
>         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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to