<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Great. You made my day :)<div><br><div><div>Am 04.03.2013 um 09:20 schrieb Arturo Martín Lladó <<a href="mailto:arturo.martin.llado@gmail.com">arturo.martin.llado@gmail.com</a>>:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi,<br><br>I want to apologize about this issue. I was compiling my custum widget<br>linking against OpenCms 8.5 JARs. That was the reason I couldn't get<br>the breakpoints of some methods working on debug mode...<br><br>I solved the locale issue this way:<br><br>1. In the XSD schema I added this:<br><br><xsd:annotation><br><span class="Apple-tab-span" style="white-space:pre">      </span><span class="Apple-tab-span" style="white-space:pre">    </span><xsd:appinfo><br><span class="Apple-tab-span" style="white-space:pre">       </span><span class="Apple-tab-span" style="white-space:pre">    </span>    <resourcebundles><br>                <xmlbundle name="mypackage.contrato.xml"><br>                    <bundle locale="ca"><br>                        <resource<br>key="mypackage.contrato.language">ca</resource><br>                    </bundle><br>                    <bundle locale="es"><br>                        <resource<br>key="mypackage.contrato.language">es</resource><br>                    </bundle><br>                </xmlbundle><br>            </resourcebundles><br>[...]<br><br><layouts><br>    <layout element="tipoContrato" widget="LocaleCategoryWidget"<br>configuration="category=/_categories/%(key.mypackage.contrato.language)/tipoContrato/"<br>/><br>[...]<br><br>2. And this is the code for my custum category widget, extending from<br>CmsCategoryWidget:<br><br>public class CmsLocaleCategoryWidget extends CmsCategoryWidget {<br><span class="Apple-tab-span" style="white-space:pre">       </span><br><span class="Apple-tab-span" style="white-space:pre">  </span>/**<br><span class="Apple-tab-span" style="white-space:pre">       </span>* Creates a new category widget.<p><br><span class="Apple-tab-span" style="white-space:pre"> </span>*/<br>    public CmsLocaleCategoryWidget() {<br>        // empty constructor is required for class registration<br>        super();<br>    }<br><br>    /**<br><span class="Apple-tab-span" style="white-space:pre">        </span>* Creates a category widget with the specified options.<p><br><span class="Apple-tab-span" style="white-space:pre">  </span>*<br><span class="Apple-tab-span" style="white-space:pre"> </span>* @param configuration the configuration for the widget<br><span class="Apple-tab-span" style="white-space:pre">   </span>*/<br>    public CmsLocaleCategoryWidget(String configuration) {<br>        super(configuration);<br>    }<br><br><span class="Apple-tab-span" style="white-space:pre">   </span>/**<br><span class="Apple-tab-span" style="white-space:pre">       </span>* @see org.opencms.widgets.I_CmsWidget#newInstance()<br><span class="Apple-tab-span" style="white-space:pre">      </span>*/<br>    public I_CmsWidget newInstance() {<br>        return new CmsLocaleCategoryWidget(getConfiguration());<br>    }<br><span class="Apple-tab-span" style="white-space:pre">       </span><br><span class="Apple-tab-span" style="white-space:pre">  </span>/**<br><span class="Apple-tab-span" style="white-space:pre">       </span>* @see org.opencms.widgets.I_CmsADEWidget#getConfiguration(org.opencms.file.CmsObject,<br>org.opencms.xml.types.A_CmsXmlContentValue,<br>org.opencms.i18n.CmsMessages, org.opencms.file.CmsResource,<br>java.util.Locale)<br><span class="Apple-tab-span" style="white-space:pre">       </span>*/<br>    public String getConfiguration(<br>        CmsObject cms,<br>        A_CmsXmlContentValue schemaType,<br>        CmsMessages messages,<br>        CmsResource resource,<br>        Locale contentLocale) {<br>    <span class="Apple-tab-span" style="white-space:pre"> </span><br>    <span class="Apple-tab-span" style="white-space:pre">       </span>String result = super.getConfiguration(cms, schemaType, messages,<br>resource, contentLocale);<br><br>        ResourceBundle bundle =<br>schemaType.getContentDefinition().getContentHandler().<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">    </span>getMessages(contentLocale).getResourceBundle();<br>        Set<String> keySet = bundle.keySet();<br><br>        for (String bundleKey : keySet) {<br>        <span class="Apple-tab-span" style="white-space:pre">        </span><br>        <span class="Apple-tab-span" style="white-space:pre">       </span>// Resourcebundle's keys for OpenCms are specified this way:<br>%(key.name.of.string)<br>        <span class="Apple-tab-span" style="white-space:pre">    </span>String xsdKey = "%(key." + bundleKey +  ")";<br>        <span class="Apple-tab-span" style="white-space:pre">  </span><br>        <span class="Apple-tab-span" style="white-space:pre">       </span>if ( result.contains(xsdKey) )<br>        <span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre">    </span>result = result.replace(xsdKey, bundle.getString(bundleKey));<br>        <span class="Apple-tab-span" style="white-space:pre">  </span><br>        }<br><br>        return result;<br><br>    }<br><br>}<br><br>3. Now, when editing the content, the starting category is shown<br>according the locale we are editing at the moment<br>(/_categories/es/tipoContrato/ or /_categories/ca/tipoContrato).<br><br>I hope this can help to someone.<br><br>Thanks a lot again, list.<br><br>================<br>Arturo Martín Lladó<br>================<br><br>2013/2/18 Arturo Martín Lladó <<a href="mailto:arturo.martin.llado@gmail.com">arturo.martin.llado@gmail.com</a>>:<br><blockquote type="cite">Hi again, Christoph:<br><br>Thank you for your help!<br><br>Now more things are happening, but the method getStartingCategory()<br>stills not being called.<br>I see that the methods that are being called using the widget are:<br><br>- Empty constructor.<br>- setConfiguration(java.lang.String configuration)<br>- getConfiguration()<br><br>I guess that I can do what I need inside setConfiguration. I'll keep<br>you posted :-)<br><br>Kind regards,<br>Arturo.<br><br>2013/2/18 Christoph Fröhlich <<a href="mailto:cfauto@folge2.de">cfauto@folge2.de</a>>:<br><blockquote type="cite">Hi Arturo,<br><br>sorry. I forgot that you have to overwrite<br><br>newInstance()<br><br>as well.<br><br>/**<br>* @see org.opencms.widgets.I_CmsWidget#newInstance()<br>*/<br>public I_CmsWidget newInstance() {<br><br>return new CmsLocaleCategoryWidget();<br>}<br><br>I hope this should do the trick.<br><br>Regards<br>Christoph<br><br>Am 18.02.2013 um 12:05 schrieb Arturo Martín Lladó<br><<a href="mailto:arturo.martin.llado@gmail.com">arturo.martin.llado@gmail.com</a>>:<br><br>Hi, Christoph:<br><br>It's really wierd. I have subclassed the widget like this:<br><br>[...]<br><br>public class CmsLocaleCategoryWidget extends CmsCategoryWidget {<br><br>private static Log LOG = CmsLog.getLog(CmsLocaleCategoryWidget.class);<br><br>public String getStartingCategory(CmsObject cms, java.lang.String<br>referencePath) {<br><br>LOG.error("== getStartingCategory, referencePath =>" + referencePath);<br>LOG.error("== getStartingCategory =>" +<br>super.getStartingCategory(cms, referencePath));<br>return super.getStartingCategory(cms, referencePath);<br><br>}<br><br>}<br><br>I also changed the XSD and opencms-vfs.xml in order to use the new widget.<br><br>The "new" widget is rendered ok, showing categories, but I see no<br>output in opencms.log. Even starting Tomcat on debug mode and adding a<br>breakpoint on the method does not trigger anything. No stop in the<br>method. It seems the method is not being called. I just don't get<br>it...<br><br>Thank you anyway for the help, Christoph. It is very welcome :-)<br><br>Cheers.<br><br>2013/2/16 Christoph Fröhlich <<a href="mailto:cfauto@folge2.de">cfauto@folge2.de</a>>:<br><br>HI Arturo,<br><br>maybe you can create a custom widget by subclassing<br> org.opencms.widgets.CmsCategoryWidget<br><br><br>In the method<br> getStartingCategory(CmsObject, String)<br><br>you have access to the current locale. I think this should enable you to<br>construct locale dependent starting categories.<br><br>Regards<br>Christoph<br><br>Am 15.02.2013 um 17:51 schrieb Rüdiger Kurz <<a href="mailto:r.kurz@alkacon.com">r.kurz@alkacon.com</a>>:<br><br>Hi,<br><br>OK, enable the content managers to create categories and localize the<br>display values is an argument. Anyway it would be better using the same<br>taxonomy.<br><br>If you have only two locales an 'ugly' workaround would be using two<br>properties: simple and straight, but technical not clean. So why don't<br>create an 'config' XSD that has multiple nested elements holding a category<br>together with its display name. This will make it easy to edit the localized<br>display values in a comfortable way for content managers and it would be<br>technically clean.<br><br>You could initialize this content with a Java Bean or what ever you need to<br>make access easier than writing scriplet code.<br><br>@Tobias, sorry but your mail comes in while I've already used the word<br>'ugly', anyway the property variant is simple and straight.<br><br>regards<br>Rüdiger<br><br><br>Am 15.02.2013 17:18, schrieb Arturo Martín Lladó:<br><br>Hi, Rüdiger.<br><br>I can say it's a very original solution :-)<br><br>Unfortunately, the categories should be administrated (and localized,<br>they are siblings with different Title property) by the final users,<br>and the edition of a Java properties file it's not a solution suitable<br>for them.<br><br>That's why we have a categories taxonomy like this:<br><br>=====<br>/_categories<br>   ca<br>       categories with locale "ca" configured as property by the parent<br>       [...]<br>   es<br>       categories with locale "es" configured as property by the parent<br>       [...]<br>=====<br><br>and that's why we'd like to offer to the final user a default category<br>pointed using de "configuration" attribute of the CategoryWidget.<br><br>Thank you anyway, Rüdiger. I really appreciate your help and any other<br>tip about this problem will be very welcome.<br><br>I guess that support for macros processing on the "configuration"<br>attribute of the layout widgets could be part of the wishlist of the<br>next release of OpenCms :-)<br><br>Again, thanks for your help and have a nice weekend.<br><br>Regards.<br><br>2013/2/15 Rüdiger Kurz <<a href="mailto:r.kurz@alkacon.com">r.kurz@alkacon.com</a>>:<br><br>Hi,<br><br>think you are right with your assumption. What you're trying to archive is<br>localization of categories. I might be wrong, but I think that localizing<br>categories,tags,facets,... does not make that much sense, since the 'tags'<br>should be the same for one content. (Categories are assigned to VFS<br>resources not to the real-localized content).<br><br>However, I would try to use the same taxonomy for all languages and then<br>localize its output at rendering time: The messages.properties could have<br>entries per category path, using dots instead slashes and then on JSP side<br>you will replace the slashes pf the category path with dotes and try then to<br>receive the localized value.<br><br>What do you think?<br><br>Am 15.02.2013 16:49, schrieb Arturo Martín Lladó:<br><br>Hi, Rüdiger.<br><br>I tried with this:<br><br>           <resourcebundles><br>                <xmlbundle name="element.workplace.xml"><br>                    <bundle locale="ca"><br>                        <resource<br>key="package.element.language">ca</resource><br>                    </bundle><br>                    <bundle locale="es"><br>                        <resource<br>key="package.element.language">es</resource><br>                    </bundle><br>                </xmlbundle><br>            </resourcebundles><br><br>The value stored in %(key.package.element.language) is displayed OK in<br>the default values of OpenCmsString fields, but it seems to be ignored<br>in the attribute "configuration" of a CategoryWidget.<br><br>Is this the expected behaviour? Maybe macros are not processed in<br><layout> elements?<br><br>Kind regards.<br><br>2013/2/15 Rüdiger Kurz <<a href="mailto:r.kurz@alkacon.com">r.kurz@alkacon.com</a>>:<br><br><br>Hi,<br><br>it's me again. You can access localized message bundles with:<br>%(key.your.label)<br><br>imagine a XSD:<br><br><resourcebundle name="your.package.workplace"/><br>[...]<br><layout element="Elem"<br>        widget="CategoryWidget"<br>        configuration="... %(key.language) ..." /><br><br>and a workplace_en.properties<br>containing:<br>language=en<br><br>and a workplace_de.properties<br>containing:<br>language=de<br><br>This should do the trick.<br><br>regards<br>Rüdiger<br><br><br>Am 15.02.2013 14:39, schrieb Rüdiger Kurz:<br><br>sorry not quiet sure if this works inside the XSD, but inside the<br>content editor you can use it.<br><br>Am 15.02.2013 14:37, schrieb Rüdiger Kurz:<br><br><br><br>yes, %(request.locale)<br><br>Am 15.02.2013 14:27, schrieb Arturo Martín Lladó:<br><br><br><br>Hi, list.<br><br>Is there available any locale macro for using it in XSD schemas?<br><br>I'd like to do something like this:<br><br>    <layouts><br>                 [...]<br>                 <layout element="Categoria" widget="CategoryWidget"<br><br><br>configuration="category=/_categories/__LOCALE_MACRO___/tipoDocumento/|onlyleafs=true"/><br><br><br>    </layouts><br><br>This is because our categories tree is organized this way:<br>/sites/default/_categories/__LOCALE__/...<br><br>Kind regards.<br><br><br><br><br><br>--<br>Rüdiger Kurz<br><br>-------------------<br><br>Alkacon Software GmbH - The OpenCms Experts<br>Rüdiger Kurz<br>An der Wachsfabrik 13<br>50996 Koeln, DE<br><br>Tel: +49 (0)2236 3826-16<br>Fax: +49 (0)2236 3826-20<br>Email: <a href="mailto:r.kurz@alkacon.com">r.kurz@alkacon.com</a><br><br><a href="http://www.alkacon.com">http://www.alkacon.com</a><br>http://www.opencms.org<br><br>Geschäftsführer: Alexander Kandzior, Amtsgericht Köln, HRB 54613<br>_______________________________________________<br>This mail is sent to you from the opencms-dev mailing list<br>To change your list options, or to unsubscribe from the list, please visit<br>http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev<br><br><br><br><br><br><br><br><br>_______________________________________________<br>This mail is sent to you from the opencms-dev mailing list<br>To change your list options, or to unsubscribe from the list, please visit<br>http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev<br><br><br><br><br><br><br><br>--<br>Arturo Martín Lladó<br><br><br>-------------------------------------------------<br>Christoph Fröhlich<br>Folge 3 GmbH<br>Neuer Pferdemarkt 1<br>20359 Hamburg<br><br>+49 +40  79 69 48 78<br>cf@folge3.de<br>http://www.folge3.de<br>-------------------------------------------------<br>Geschäftsführer: Christoph Fröhlich, Anja Künzel<br>Handelsregister: HRB 105806, Amtsgericht Hamburg<br><br><br><br><br><br><br><br></blockquote><br><br><br>--<br>Arturo Martín Lladó<br></blockquote></blockquote></div><br><div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">-------------------------------------------------<br><div style="font-size: 12px; margin: 0px; ">Christoph Fröhlich</div>Folge 3 GmbH<div style="margin: 0px; ">Neuer Pferdemarkt 1</div><div style="margin: 0px; ">20359 Hamburg</div><div style="margin: 0px; "><br>+49 +40  79 69 48 78<br><a href="mailto:cf@folge3.de">cf@folge3.de</a></div><div style="font-size: 12px; margin: 0px; "><a href="http://www.folge3.de">http://www.folge3.de</a></div><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="margin: 0px; ">-------------------------------------------------<br>Geschäftsführer: Christoph Fröhlich, Anja Künzel<br>Handelsregister: HRB 105806, Amtsgericht Hamburg </div></span></span></span></span></div></span></div></span></div></span></span></div></div></div></div></div></div>
</div>
<br></div></body></html>