Author: jacopoc
Date: Fri Feb 24 12:12:00 2012 New Revision: 1293204 URL: http://svn.apache.org/viewvc?rev=1293204&view=rev Log: OFBIZ-4715: implemented new mechanism to dynamically select (if available) a country specific ftl template to render the postal address on screen. Based on an initial patch contributed by Markus M. May Added: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetPostalAddressTemplate.groovy (with props) ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/ ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress.ftl (with props) ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.ftl (with props) Modified: ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Contact.ftl ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml Added: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetPostalAddressTemplate.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetPostalAddressTemplate.groovy?rev=1293204&view=auto ============================================================================== --- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetPostalAddressTemplate.groovy (added) +++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetPostalAddressTemplate.groovy Fri Feb 24 12:12:00 2012 @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +postalAddress = request.getAttribute("postalAddress"); + +if (postalAddress && postalAddress.countryGeoId) { + postalAddressTemplate = "PostalAddress_" + postalAddress.countryGeoId + ".ftl"; + file = new File(addressTemplatePath + postalAddressTemplate); + if (file.exists()) { + context.postalAddressTemplate = postalAddressTemplate; + } +} +if (!context.postalAddressTemplate) { + context.postalAddressTemplate = "PostalAddress.ftl"; +} + +context.postalAddress = postalAddress; Propchange: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetPostalAddressTemplate.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetPostalAddressTemplate.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetPostalAddressTemplate.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress.ftl?rev=1293204&view=auto ============================================================================== --- ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress.ftl (added) +++ ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress.ftl Fri Feb 24 12:12:00 2012 @@ -0,0 +1,43 @@ +<#-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + <div> + <#if postalAddress.toName?has_content><b>${uiLabelMap.PartyAddrToName}:</b> ${postalAddress.toName}<br /></#if> + <#if postalAddress.attnName?has_content><b>${uiLabelMap.PartyAddrAttnName}:</b> ${postalAddress.attnName}<br /></#if> + ${postalAddress.address1?if_exists}<br /> + <#if postalAddress.address2?has_content>${postalAddress.address2}<br /></#if> + ${postalAddress.city?if_exists}, + <#if postalAddress.stateProvinceGeoId?has_content> + <#assign stateProvince = postalAddress.getRelatedOneCache("StateProvinceGeo")> + ${stateProvince.abbreviation?default(stateProvince.geoId)} + </#if> + ${postalAddress.postalCode?if_exists} + <#if postalAddress.countryGeoId?has_content><br /> + <#assign country = postalAddress.getRelatedOneCache("CountryGeo")> + ${country.get("geoName", locale)?default(country.geoId)} + </#if> + </div> + <#if !postalAddress.countryGeoId?has_content> + <#assign addr1 = postalAddress.address1?if_exists> + <#if addr1?has_content && (addr1.indexOf(" ") > 0)> + <#assign addressNum = addr1.substring(0, addr1.indexOf(" "))> + <#assign addressOther = addr1.substring(addr1.indexOf(" ")+1)> + <a target="_blank" href="${uiLabelMap.CommonLookupWhitepagesAddressLink}" class="buttontext">${uiLabelMap.CommonLookupWhitepages}</a> + </#if> + </#if> + Propchange: ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress.ftl ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress.ftl ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress.ftl ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.ftl?rev=1293204&view=auto ============================================================================== --- ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.ftl (added) +++ ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.ftl Fri Feb 24 12:12:00 2012 @@ -0,0 +1,40 @@ +<#-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + <div> + <#if postalAddress.toName?has_content><b>${uiLabelMap.PartyAddrToName}:</b> ${postalAddress.toName}<br /></#if> + <#if postalAddress.attnName?has_content><b>${uiLabelMap.PartyAddrAttnName}:</b> ${postalAddress.attnName}<br /></#if> + ${postalAddress.address1?if_exists}<br /> + <#if postalAddress.address2?has_content>${postalAddress.address2}<br /></#if> + ${postalAddress.city?if_exists}, + <#if postalAddress.stateProvinceGeoId?has_content> + <#assign stateProvince = postalAddress.getRelatedOneCache("StateProvinceGeo")> + ${stateProvince.abbreviation?default(stateProvince.geoId)} + </#if> + ${postalAddress.postalCode?if_exists} + <#if postalAddress.countryGeoId?has_content><br /> + <#assign country = postalAddress.getRelatedOneCache("CountryGeo")> + ${country.get("geoName", locale)?default(country.geoId)} + </#if> + </div> + <#assign addr1 = postalAddress.address1?if_exists> + <#if addr1?has_content && (addr1.indexOf(" ") > 0)> + <#assign addressNum = addr1.substring(0, addr1.indexOf(" "))> + <#assign addressOther = addr1.substring(addr1.indexOf(" ")+1)> + <a target="_blank" href="${uiLabelMap.CommonLookupWhitepagesAddressLink}" class="buttontext">${uiLabelMap.CommonLookupWhitepages}</a> + </#if> Propchange: ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.ftl ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.ftl ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.ftl ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Contact.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Contact.ftl?rev=1293204&r1=1293203&r2=1293204&view=diff ============================================================================== --- ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Contact.ftl (original) +++ ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Contact.ftl Fri Feb 24 12:12:00 2012 @@ -58,35 +58,9 @@ under the License. </#list> <#if "POSTAL_ADDRESS" = contactMech.contactMechTypeId> <#if contactMechMap.postalAddress?has_content> - <#assign postalAddress = contactMechMap.postalAddress> - </#if> - <#if postalAddress?has_content> - <div> - <#if postalAddress.toName?has_content><b>${uiLabelMap.PartyAddrToName}:</b> ${postalAddress.toName}<br /></#if> - <#if postalAddress.attnName?has_content><b>${uiLabelMap.PartyAddrAttnName}:</b> ${postalAddress.attnName}<br /></#if> - ${postalAddress.address1?if_exists}<br /> - <#if postalAddress.address2?has_content>${postalAddress.address2}<br /></#if> - ${postalAddress.city?if_exists}, - <#if postalAddress.stateProvinceGeoId?has_content> - <#assign stateProvince = postalAddress.getRelatedOneCache("StateProvinceGeo")> - ${stateProvince.abbreviation?default(stateProvince.geoId)} - </#if> - ${postalAddress.postalCode?if_exists} - <#if postalAddress.countryGeoId?has_content><br /> - <#assign country = postalAddress.getRelatedOneCache("CountryGeo")> - ${country.geoName?default(country.geoId)} - </#if> - </div> - </#if> - <#if postalAddress?has_content> - <#if !postalAddress.countryGeoId?has_content || postalAddress.countryGeoId = "USA"> - <#assign addr1 = postalAddress.address1?if_exists> - <#if addr1?has_content && (addr1.indexOf(" ") > 0)> - <#assign addressNum = addr1.substring(0, addr1.indexOf(" "))> - <#assign addressOther = addr1.substring(addr1.indexOf(" ")+1)> - <a target="_blank" href="${uiLabelMap.CommonLookupWhitepagesAddressLink}" class="buttontext">${uiLabelMap.CommonLookupWhitepages}</a> - </#if> - </#if> + <#assign postalAddress = contactMechMap.postalAddress> + ${setRequestAttribute("postalAddress", postalAddress)} + ${screens.render("component://party/widget/partymgr/PartyScreens.xml#postalAddress")} <#if postalAddress.geoPointId?has_content> <#if contactMechPurposeType?has_content> <#assign popUptitle = contactMechPurposeType.get("description",locale) + uiLabelMap.CommonGeoLocation> Modified: ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml?rev=1293204&r1=1293203&r2=1293204&view=diff ============================================================================== --- ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml (original) +++ ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml Fri Feb 24 12:12:00 2012 @@ -1254,4 +1254,21 @@ under the License. </widgets> </section> </screen> + <screen name="postalAddress"> + <section> + <actions> + <property-map resource="PartyUiLabels" map-name="uiLabelMap" global="true"/> + <set field="addressTemplatePath" value="${sys:getProperty('ofbiz.home')}/applications/party/webapp/partymgr/party/contactmechtemplates/"/> + <set field="postalAddress" from-field="parameters.postalAddress"/> + <script location="component://party/webapp/partymgr/WEB-INF/actions/party/GetPostalAddressTemplate.groovy"/> + </actions> + <widgets> + <platform-specific> + <html> + <html-template location="component://party/webapp/partymgr/party/contactmechtemplates/${postalAddressTemplate}"/> + </html> + </platform-specific> + </widgets> + </section> + </screen> </screens> |
Free forum by Nabble | Edit this page |