Hi Jacopo I have a problem with this commit.
On Tue, Mar 27, 2012 at 11:48 PM, <[email protected]> wrote: > Author: jacopoc > Date: Tue Mar 27 16:48:54 2012 > New Revision: 1305898 > > URL: http://svn.apache.org/viewvc?rev=1305898&view=rev > Log: > OFBIZ-4715 Committed patch from Markus M. May to extend the country > specific address formatter to PDF (fo.ftl). > > > Added: > > > ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress.fo.ftl > (with props) > > > ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.fo.ftl > (with props) > Modified: > > ofbiz/trunk/applications/order/webapp/ordermgr/order/companyHeader.fo.ftl > > ofbiz/trunk/applications/order/webapp/ordermgr/order/ordercontactinfo.ftl > > > ofbiz/trunk/applications/order/webapp/ordermgr/quote/quoteReportContactMechs.fo.ftl > > > ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetPostalAddressTemplate.groovy > > > ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.ftl > > > ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Contact.ftl > ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml > > Modified: > ofbiz/trunk/applications/order/webapp/ordermgr/order/companyHeader.fo.ftl > URL: > http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/companyHeader.fo.ftl?rev=1305898&r1=1305897&r2=1305898&view=diff > > ============================================================================== > --- > ofbiz/trunk/applications/order/webapp/ordermgr/order/companyHeader.fo.ftl > (original) > +++ > ofbiz/trunk/applications/order/webapp/ordermgr/order/companyHeader.fo.ftl > Tue Mar 27 16:48:54 2012 > @@ -26,9 +26,8 @@ under the License. > <fo:block>${companyName}</fo:block> > <#if postalAddress?exists> > <#if postalAddress?has_content> > - <fo:block>${postalAddress.address1?if_exists}</fo:block> > - <#if > postalAddress.address2?has_content><fo:block>${postalAddress.address2?if_exists}</fo:block></#if> > - <fo:block>${postalAddress.city?if_exists}, > ${stateProvinceAbbr?if_exists} ${postalAddress.postalCode?if_exists}, > ${countryName?if_exists}</fo:block> > + ${setRequestAttribute("postalAddress", postalAddress)} > + > > ${screens.render("component://party/widget/partymgr/PartyScreens.xml#postalAddressPdfFormatter")} > </#if> > <#else> > <fo:block>${uiLabelMap.CommonNoPostalAddress}</fo:block> > Calling setRequestAttribute template method will work fine in companyHeader.fo.ftl if I print a PDF report in a web page which has a request object but it will not work if I send the PDF report through email using a service because there is NOT a request object in a service. > > Modified: > ofbiz/trunk/applications/order/webapp/ordermgr/order/ordercontactinfo.ftl > URL: > http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/ordercontactinfo.ftl?rev=1305898&r1=1305897&r2=1305898&view=diff > > ============================================================================== > --- > ofbiz/trunk/applications/order/webapp/ordermgr/order/ordercontactinfo.ftl > (original) > +++ > ofbiz/trunk/applications/order/webapp/ordermgr/order/ordercontactinfo.ftl > Tue Mar 27 16:48:54 2012 > @@ -117,21 +117,8 @@ under the License. > <#assign postalAddress = > orderContactMechValueMap.postalAddress> > <#if postalAddress?has_content> > <div> > - <#if postalAddress.toName?has_content><span > class="label">${uiLabelMap.CommonTo}</span> ${postalAddress.toName}<br > /></#if> > - <#if postalAddress.attnName?has_content><span > class="label">${uiLabelMap.CommonAttn}</span> ${postalAddress.attnName}<br > /></#if> > - ${postalAddress.address1}<br /> > - <#if > postalAddress.address2?has_content>${postalAddress.address2}<br /></#if> > - ${postalAddress.city?if_exists}<#if > postalAddress.stateProvinceGeoId?has_content>, > ${postalAddress.stateProvinceGeoId} </#if> > - ${postalAddress.postalCode?if_exists}<br /> > - ${postalAddress.countryGeoId?if_exists}<br /> > - <#if !postalAddress.countryGeoId?exists || > postalAddress.countryGeoId == "USA"> > - <#assign addr1 = postalAddress.address1?if_exists> > - <#if (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> > + ${setRequestAttribute("postalAddress", > postalAddress)} > + > ${screens.render("component://party/widget/partymgr/PartyScreens.xml#postalAddressHtmlFormatter")} > </div> > <@updateOrderContactMech > orderHeader=orderHeader?if_exists > contactMechTypeId=contactMech.contactMechTypeId > contactMechList=postalContactMechList?if_exists > contactMechPurposeTypeId=contactMechPurpose.contactMechPurposeTypeId?if_exists > contactMechAddress=postalAddress?if_exists /> > </#if> > > Modified: > ofbiz/trunk/applications/order/webapp/ordermgr/quote/quoteReportContactMechs.fo.ftl > URL: > http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/quote/quoteReportContactMechs.fo.ftl?rev=1305898&r1=1305897&r2=1305898&view=diff > > ============================================================================== > --- > ofbiz/trunk/applications/order/webapp/ordermgr/quote/quoteReportContactMechs.fo.ftl > (original) > +++ > ofbiz/trunk/applications/order/webapp/ordermgr/quote/quoteReportContactMechs.fo.ftl > Tue Mar 27 16:48:54 2012 > @@ -39,9 +39,8 @@ under the License. > <fo:table-cell> > <fo:block> > <#if toPostalAddress?exists> > - > <fo:block>${toPostalAddress.address1?if_exists}</fo:block> > - > <fo:block>${toPostalAddress.address2?if_exists}</fo:block> > - > <fo:block>${toPostalAddress.city?if_exists}<#if > toPostalAddress.stateProvinceGeoId?has_content>, > ${toPostalAddress.stateProvinceGeoId}</#if> > ${toPostalAddress.postalCode?if_exists}</fo:block> > + ${setRequestAttribute("postalAddress", > toPostalAddress)} > + > ${screens.render("component://party/widget/partymgr/PartyScreens.xml#postalAddressPdfFormatter")} > </#if> > </fo:block> > </fo:table-cell> > > Modified: > 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=1305898&r1=1305897&r2=1305898&view=diff > > ============================================================================== > --- > ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetPostalAddressTemplate.groovy > (original) > +++ > ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/GetPostalAddressTemplate.groovy > Tue Mar 27 16:48:54 2012 > @@ -17,17 +17,21 @@ > * under the License. > */ > > -postalAddress = request.getAttribute("postalAddress"); > +postalAddressForTemplate = request.getAttribute("postalAddress"); > +postalAddressTemplateSuffix = context.postalAddressTemplateSuffix; > > -if (postalAddress && postalAddress.countryGeoId) { > - postalAddressTemplate = "PostalAddress_" + postalAddress.countryGeoId > + ".ftl"; > +if (!postalAddressTemplateSuffix) { > + postalAddressTemplateSuffix = ".ftl"; > +} > + > +if (postalAddressForTemplate && postalAddressForTemplate.countryGeoId) { > + postalAddressTemplate = "PostalAddress_" + > postalAddressForTemplate.countryGeoId + postalAddressTemplateSuffix; > file = new File(addressTemplatePath + postalAddressTemplate); > - if (file.exists()) { > + if (file.exists()) { > context.postalAddressTemplate = postalAddressTemplate; > + } else { > + context.postalAddressTemplate = "PostalAddress" + > postalAddressTemplateSuffix; > } > } > -if (!context.postalAddressTemplate) { > - context.postalAddressTemplate = "PostalAddress.ftl"; > -} > > -context.postalAddress = postalAddress; > +context.postalAddress = postalAddressForTemplate; > > Added: > ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress.fo.ftl > URL: > http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress.fo.ftl?rev=1305898&view=auto > > ============================================================================== > --- > ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress.fo.ftl > (added) > +++ > ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress.fo.ftl > Tue Mar 27 16:48:54 2012 > @@ -0,0 +1,27 @@ > +<#-- > +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. > +--> > + <fo:block>${postalAddress.address1?if_exists}</fo:block> > + <#if > postalAddress.address2?has_content><fo:block>${postalAddress.address2?if_exists}</fo:block></#if> > + <fo:block>${postalAddress.city?if_exists}<#if > postalAddress.stateProvinceGeoId?has_content>, > ${postalAddress.stateProvinceGeoId}</#if> > ${postalAddress.postalCode?if_exists}</fo:block> > + <#if postalAddress.countryGeoId?has_content> > + <fo:block> > + <#assign country = > postalAddress.getRelatedOneCache("CountryGeo")> > + ${country.get("geoName", locale)?default(country.geoId)} > + </fo:block> > + </#if> > > Propchange: > ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress.fo.ftl > > ------------------------------------------------------------------------------ > svn:eol-style = native > > Propchange: > ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress.fo.ftl > > ------------------------------------------------------------------------------ > svn:keywords = Date Rev Author URL Id > > Propchange: > ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress.fo.ftl > > ------------------------------------------------------------------------------ > svn:mime-type = text/plain > > Added: > ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.fo.ftl > URL: > http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.fo.ftl?rev=1305898&view=auto > > ============================================================================== > --- > ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.fo.ftl > (added) > +++ > ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.fo.ftl > Tue Mar 27 16:48:54 2012 > @@ -0,0 +1,27 @@ > +<#-- > +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. > +--> > + <fo:block>${postalAddress.address1?if_exists}</fo:block> > + <#if > postalAddress.address2?has_content><fo:block>${postalAddress.address2?if_exists}</fo:block></#if> > + <fo:block>${postalAddress.city?if_exists}<#if > postalAddress.stateProvinceGeoId?has_content>, > ${postalAddress.stateProvinceGeoId}</#if> > ${postalAddress.postalCode?if_exists}</fo:block> > + <#if postalAddress.countryGeoId?has_content> > + <fo:block> > + <#assign country = > postalAddress.getRelatedOneCache("CountryGeo")> > + ${country.get("geoName", locale)?default(country.geoId)} > + </fo:block> > + </#if> > > Propchange: > ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.fo.ftl > > ------------------------------------------------------------------------------ > svn:eol-style = native > > Propchange: > ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.fo.ftl > > ------------------------------------------------------------------------------ > svn:keywords = Date Rev Author URL Id > > Propchange: > ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.fo.ftl > > ------------------------------------------------------------------------------ > svn:mime-type = text/plain > > Modified: > 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=1305898&r1=1305897&r2=1305898&view=diff > > ============================================================================== > --- > ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.ftl > (original) > +++ > ofbiz/trunk/applications/party/webapp/partymgr/party/contactmechtemplates/PostalAddress_USA.ftl > Tue Mar 27 16:48:54 2012 > @@ -32,9 +32,12 @@ under the License. > ${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> > + > > 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=1305898&r1=1305897&r2=1305898&view=diff > > ============================================================================== > --- > ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Contact.ftl > (original) > +++ > ofbiz/trunk/applications/party/webapp/partymgr/party/profileblocks/Contact.ftl > Tue Mar 27 16:48:54 2012 > @@ -60,10 +60,10 @@ under the License. > <#if contactMechMap.postalAddress?has_content> > <#assign postalAddress = > contactMechMap.postalAddress> > ${setRequestAttribute("postalAddress", > postalAddress)} > - > ${screens.render("component://party/widget/partymgr/PartyScreens.xml#postalAddress")} > + > ${screens.render("component://party/widget/partymgr/PartyScreens.xml#postalAddressHtmlFormatter")} > <#if postalAddress.geoPointId?has_content> > <#if contactMechPurposeType?has_content> > - <#assign popUptitle = > contactMechPurposeType.get("description",locale) + > uiLabelMap.CommonGeoLocation> > + <#assign popUptitle = > contactMechPurposeType.get("description", locale) + > uiLabelMap.CommonGeoLocation> > </#if> > <a > href="javascript:popUp('<@ofbizUrl>PartyGeoLocation?geoPointId=${postalAddress.geoPointId}&partyId=${partyId}</@ofbizUrl>', > '${popUptitle?if_exists}', '450', '550')" > class="buttontext">${uiLabelMap.CommonGeoLocation}</a> > </#if> > > Modified: ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml > URL: > http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml?rev=1305898&r1=1305897&r2=1305898&view=diff > > ============================================================================== > --- ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml > (original) > +++ ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml Tue > Mar 27 16:48:54 2012 > @@ -1254,12 +1254,29 @@ under the License. > </widgets> > </section> > </screen> > - <screen name="postalAddress"> > + <screen name="postalAddressHtmlFormatter"> > <section> > <actions> > <property-map resource="PartyUiLabels" > map-name="uiLabelMap" global="true"/> > + <set field="postalAddressTemplateSuffix" value=".ftl"/> > + <set field="addressTemplatePath" > value="${sys:getProperty('ofbiz.home')}/applications/party/webapp/partymgr/party/contactmechtemplates/"/> > + <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> > + <screen name="postalAddressPdfFormatter"> > + <section> > + <actions> > + <property-map resource="PartyUiLabels" > map-name="uiLabelMap" global="true"/> > + <set field="postalAddressTemplateSuffix" value=".fo.ftl"/> > <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> > > > Regards, Chatree Srichart
