[opencms-dev] Antwort: Re: Sorting of elements with cms:contentload

Frank Pertack fpertack at vater-gruppe.de
Mon Sep 20 12:21:27 CEST 2010


Hi Rüdiger,

long time ago you answered my request "Sorting of elements with
cms:contentload".
But not until today we tried to realize your proposal. And we encountered
some problems:
   We wrote our own ResourceCollector by using
   org.opencms.file.collectors.CmsDefaultResourceCollector as template for
   our own,

   we added an additional parameter "companySort" to this collector,
   indicating the column we like to sort.

   and we copied the class into the class directory of the module:
   /system/modules/org.vug.templates/classes/org/vug/templates/

   We added a line in the collectors-node of the opencms-vfs.xml.
   <collectors>
    <collector class="org.vug.templates.CmsVaterResourceCollector"
   order="90"/>
    <collector
   class="org.opencms.file.collectors.CmsPriorityResourceCollector"
   order="100"/>
    <collector
   class="org.opencms.file.collectors.CmsDefaultResourceCollector"
   order="110"/>
    <collector class="org.opencms.file.collectors.CmsDateResourceCollector"
   order="120"/>
    <collector
   class="org.opencms.file.collectors.CmsTimeFrameCategoryCollector"
   order="130"/>
    <collector
   class="org.opencms.file.collectors.CmsCategoryResourceCollector"
   order="140"/>
    </collectors>
   We added the collector "companySort" in the jsp, that creates the list:
   <cms:contentload collector="companySort"
   param="/inside/telefonliste/mitarbeiter/*.html|maentry"
   editable="false">

   We wanted to test the result but somehow the jsp cannot find the new
   class, we received an error-message:
   javax.servlet.jsp.JspException: org.opencms.main.CmsException: Collector
   "companySort" was not found.
   Der Grund: Collector "companySort" wurde nicht gefunden.

   Do you have an idea which step is missing in order for the
   contentload-command to trigger the new collector-class?
   It seems that it does not even enter the new class; how is the new
   "companySort"-collector linked to the new collector-class. Is there
   another xsd or xml, that needs to be amended?

Thank you in advance for your kind support.

Frank Pertack



|------------>
| Von:       |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Rüdiger Kurz <r.kurz at alkacon.com>                                                                                                                 |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| An:        |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |The OpenCms mailing list <opencms-dev at opencms.org>                                                                                                |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Datum:     |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |20.05.2010 16:34                                                                                                                                  |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Betreff:   |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Re: [opencms-dev] Sorting of elements with cms:contentload                                                                                        |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Gesendet   |
| von:       |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |opencms-dev-bounces at opencms.org                                                                                                                   |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|





Frank,

it is possible to write your own ResourceCollector by extending the
abstract class A_CmsResourceCollector. You can use the class
org.opencms.file.collectors.CmsDefaultResourceCollector as template for
your individual collector. add an additional parameter to this collector
which indicates the column you want to search for.

Don't forget to add the new Collector into the <collectors> node of the
file opencms-vfs.xml.

For Implementation you need a comparator which compares the content of
your XML Content. For performance reasons I would recommend you to map
the Company name and the Location on a property because unmarshaling of
XML contents is an expensive Task and very complicated.

good luck ...


Am 19.05.2010 16:51, schrieb Frank Pertack:
> Hello,
>
> I have a slight problem with sorting a list of xml-documents.
> I constructed a jsp, that shows all employees of our company-group in
> alphabetical order of their lastnames.
>
> Additionally to that, I like to have a sorting by company
> (=Gesellschaft) and by location (=Standort),how do I realize this?
>
>
> When I use the following maentry.xsd, how can I change this, to make the
> contentload sort the xml-files according to a different field?
>
> code
>
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

> <!--
> XSD file for the MaEntry content type
> -->
> <!-- 1. Root Element -->
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
>
> <!-- 2. Define the location of the schema location -->
> <xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd"/>
> <!--<xsd:include
>
schemaLocation="opencms://system/modules/org.vug.templates/schemas/maentry.xsd"/>-->

>
> <!-- 3. Root element name and type of our XML type -->
> <xsd:element name="MaEntrys" type="OpenCmsMaEntrys"/>
>
> <!-- 4. Definition of the type described above -->
> <xsd:complexType name="OpenCmsMaEntrys">
> <xsd:sequence>
> <xsd:element name="MaEntry" type="OpenCmsMaEntry" minOccurs="0"
> maxOccurs="unbounded"/>
> </xsd:sequence>
> </xsd:complexType>
>
> <!-- 5. Data field definitions -->
> <xsd:complexType name="OpenCmsMaEntry">
> <xsd:sequence>
> <xsd:element name="Title" type="OpenCmsString" minOccurs="1"
> maxOccurs="1" />
> <!-- Personendaten:-->
> <xsd:element name="LastName" type="OpenCmsString" minOccurs="1"
> maxOccurs="1" />
> <xsd:element name="FirstName" type="OpenCmsString" minOccurs="1"
> maxOccurs="1" />
> <!-- Kontaktdaten:-->
> <xsd:element name="Phone" type="OpenCmsString" minOccurs="1"
> maxOccurs="1" />
> <xsd:element name="Fax" type="OpenCmsString" minOccurs="0" maxOccurs="1"
/>
> <xsd:element name="Mobile" type="OpenCmsString" minOccurs="0"
> maxOccurs="1" />
> <xsd:element name="Email" type="OpenCmsString" minOccurs="1"
> maxOccurs="1" />
> <xsd:element name="PrivatePhone" type="OpenCmsString" minOccurs="0"
> maxOccurs="1" />
> <!-- Category named "Company":-->
> <xsd:element name="Company" type="OpenCmsString" minOccurs="0"
> maxOccurs="20" />
> <xsd:element name="Location" type="OpenCmsString" minOccurs="0"
> maxOccurs="10" />
> <xsd:element name="Function" type="OpenCmsString" minOccurs="0"
> maxOccurs="1" />
> <!-- Zusatzdaten:-->
> <xsd:element name="Image" type="OpenCmsVfsFile" minOccurs="0"
> maxOccurs="1" />
> <xsd:element name="Alignment" type="OpenCmsString" minOccurs="1"
> maxOccurs="1" />
> <xsd:element name="Birthday" type="OpenCmsDateTime" minOccurs="0"
> maxOccurs="1" />
> <xsd:element name="Date" type="OpenCmsDateTime" minOccurs="1"
> maxOccurs="1" />
> <xsd:element name="Comments" type="OpenCmsString" minOccurs="0"
> maxOccurs="1" />
> </xsd:sequence>
> <xsd:attribute name="language" type="OpenCmsLocale" use="required"/>
> </xsd:complexType>
>
> <!-- 6. Annotations are used to define additional settings for our
>
content type -->
> <xsd:annotation>
> <xsd:appinfo>
> <!-- 7. Mappings allow data fields to be mapped to content properties -->
> <mappings>
> <mapping element="LastName" mapto="property:Title" />
> <mapping element="FirstName" mapto="property:Text" />
> <mapping element="Date" mapto="attribute:datereleased" />
> </mappings>
>
> <!-- 8. Validation rules may be create for field entry -->
> <validationrules>
> <!--
> <rule element="BlogText" regex="!.*[Bl]og.*" type="warning"
>
message="${key.editor.warning.BlogEntry.dontallowblog|${validation.path}}"/>

> -->
> </validationrules>
>
> <!-- 9. Default values can be set for each field type -->
> <defaults>
> <default element="Date" value="${currenttime}"/>
> <default element="Alignment" value="left"/>
> </defaults>
>
> <!-- 10. This section controls which widgets are used to edit the data
>
fields -->
> <layouts>
> <layout element="Title" widget="StringWidget"/>
> <layout element="LastName" widget="StringWidget"/>
> <layout element="FirstName" widget="StringWidget"/>
> <layout element="Phone" widget="StringWidget"/>
> <layout element="Fax" widget="StringWidget"/>
> <layout element="Mobile" widget="StringWidget"/>
> <layout element="Email" widget="StringWidget"/>
> <layout element="PrivatePhone" widget="StringWidget"/>
> <layout element="Birthday" widget="DateTimeWidget"/>
> <layout element="Date" widget="DateTimeWidget"/>
> <layout element="Image" widget="ImageGalleryWidget"/>
> <layout element="Alignment" widget="SelectorWidget"
> configuration="left|right|center" />
> <layout element="Company" widget="SelectorWidget"
> configuration="Vater 4Office GmbH|Vater Bankenberatung GmbH|Vater Bank
> IT|Vater BizCon GmbH|Vater ERPteam GmbH|
> Vater ESN Business Academy GmbH|Vater Holding GmbH|Vater KNS GmbH|Vater
> NetCom GmbH|Vater pcs GmbH|
> Vater Solution GmbH|Vater SysCon GmbH" />
> <layout element="Location" widget="SelectorWidget"
> configuration="Bremen, Herrmann-Ritter-Straße 106-114|Hamburg,
> Schellingstraße 17|Kiel, Am Kiel-Kanal 1|Kiel, Boschstraße 5|
> Kiel-Wellsee, Liebigstraße 26|Kiel-Schwentinental, Lise-Meitner-Straße
> 25-29|
> Kiel-Schwentinental, Wasserwerksweg 18" />
> <layout element="Function" widget="StringWidget"/>
> <layout element="Comments" widget="TextareaWidget"/>
> </layouts>
>
> <!-- 11. UI Localization -->
> <resourcebundle name="org.vug.templates.workplace"/>
>
> <!-- 12. this section controls relationship checking -->
> <relations>
> <relation element="Image" type="strong" invalidate="node" />
> </relations>
>
> <!-- 13. Previewing URI -->
> <preview uri="${previewtempfile}" />
>
> <!-- 14. Model Folder -->
> <modelfolder uri="/system/modules/org.vug.templates/models/" />
> </xsd:appinfo>
> </xsd:annotation>
>
> </xsd:schema>
>
> end of
>
code--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

>
> Somehow I realized, it could be working by changing the mapping of the
> title, but I don't know what to change here...:
>
> Do you have any ideas?
>
> Mit freundlichen Grüßen
>
>
>
> Frank Pertack
>
>
> Vater Solution GmbH
> Liebigstraße 26
> 24145 Kiel
>
> Telefon: +49 431 20084-210
> Telefax: +49 431 20084-222
> Mobil: +49 151 16353519
> mailto: fpertack at vater-gruppe.de
> http://www.vater-gruppe.de
>
>
>
> Amtsgericht Kiel, HRB 6403
> Geschäftsführer:
> Klaus-Hinrich Vater
> Michael Wiese
> -----
> Diese Email enthält ggfs. vertrauliche und/oder rechtlich geschützte
> Informationen. Wenn Sie nicht der richtige Adressat sind oder diese
> Email irrtümlich erhalten haben, informieren Sie bitte sofort den
> Absender und vernichten Sie diese Email. Das unerlaubte Kopieren sowie
> die unbefugte Weitergabe dieser Email sind nicht gestattet.
>
>
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please
visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev

--
Kind Regards,
Rüdiger

-------------------
Rüdiger Kurz

Alkacon Software GmbH  - The OpenCms Experts
http://www.alkacon.com - http://www.opencms.org

_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20100920/6ed8d083/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20100920/6ed8d083/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecblank.gif
Type: image/gif
Size: 45 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20100920/6ed8d083/attachment-0001.gif>


More information about the opencms-dev mailing list