[opencms-dev] Missing element that calls a customizedEventListener (Locale problem)
Martin Lehnert
martin.lehnert at hannecke-its.de
Tue Mar 29 08:51:17 CEST 2005
Hi,
I already tried the solution with a custom LocaleHandler, but the only way I figured out to handle the locale was to store the information about which locale should be used in the session of the user and get it by accessing the HttpServletRequest.
But: When I store the information about which language should be used in the session, how should the cache find out what he has to deliver? After all, there would be different language versions which can be reached by using the same URL.
Second: Statistic programs for storing access information (to find out if a special localized version of the page pays out by counting the hits for english, german, etc ...) would be useless since they also don't get what the user exactly requested.
Third: If the entire page is only usable by using caching, this would mean to have cookies activated all the time: an assumption that my client is not willing to take...
The bottom line: Is there any way to write a custom Lacale Handler without storing the information in sessions?
Greetings,
Martin Lehnert
Hannecke IT-Solutions GmbH
Martin-Luther-Str. 5b
97072 Würzburg
Tel.: 0931-99 135 12
Fax: 0931-99 135 29
Email: martin.lehnert at hannecke-its.de
-----Ursprüngliche Nachricht-----
Von: Bernd Wolfsegger [mailto:bw at code-create.com]
Gesendet: Samstag, 26. März 2005 12:51
An: opencms-dev at opencms.org
Cc: Martin Lehnert
Betreff: Re: [opencms-dev] Missing element that calls a customizedEventListener
Hi,
you don't need any siblings for language handling.
You just have to write a custom LocaleHandler and set it in the opencms-system.xml as locale handler.
And you don't have to touch the existing code for that!
Your class has to be in the package org.opencms.
Than the correct language content will be used automatically according to your likings and settings in this handler.
And there is really no need for different documents, for each language one...
Well, and that would be strange at all, to have all the different language content in one file and than have to use different files to get at the content :))
Regards, Bernd
On Thursday 24 March 2005 18:30, Martin Lehnert wrote:
> Thank you very much for the fast responses... I think the workaround
> with the servlet will do until this behaviour is implemented in OpenCms.
>
> Just one note though: The main reason why I want to create this
> Listener is because I want to simplify the OpenCms-behaviour when I
> want to add a resource in different languages. I think the existing
> implementation with saving different languages in one xml-file and the
> possibility to switch between them in the WYSIWYG-editor is really
> great, but clients find it rather cumbersome to manually add siblings
> for every language-version and configure them by adding the right locale property.
> Since I understand the necessity to have the different
> language-versions accessible through different URLs (for statistic and
> caching-reasons for
> example) I would propose another option in the workplace-context-menu
> that automatically creates siblings with an adequate pre- or postfix
> (e.g. ISO-locale-code) for every used language-version in the
> xml-control code of a resource. This behaviour could also set the
> fitting locale-property in the file's properties (perhaps it's even
> better to start this behaviour automatically as soon as you save a
> resource, while making it possible to deactivate this for people who
> don't like this because they want to organize the their
> language-versions differently).
>
> This is exactly the behaviour I want to implement through Listeners.
> Unfortunately I am to create modules without touching the
> OpenCms-source and have a very restrictive deadline, so I have to go
> the way with Listeners, otherwise I would program this behaviour
> directly into OpenCms and send it to you as a suggestion for incluing it into OpenCms.
> When I'm finished, I could send you the code of the behaviour of my
> listener, because once this is done I think it would not be too hard
> to implement it the way I suggested. As long as you think this idea is
> useful, of course.
>
> Greetings and thank you again,
> Martin Lehnert
>
> >Hello,
> >
> >Thomas Maerz wrote:
> >>"Martin Lehnert" <martin.lehnert at hannecke-its.de> writes:
> >>>I also stumbled over a class of the TemplateOne-module
> >>>(CmsTemplateParts) which is implementing the Listener-interface and
>
> is
>
> >>>used by other classes of the module, but when does the system call
>
> one
>
> >>>of those classes so that the Listener can register itself?
> >>
> >>,----[ CmsTemplateParts.java ]
> >>
> >>| // add an event listener
> >>| OpenCms.addCmsEventListener(this);
> >>
> >>`----
> >>
> >>Maybe register your Listener in a JSP, that is requested for sure by
> >>a user.
> >>
> >>I couldn't find a way to add listeners on startup, too.
> >
> >For this we have created our own small servlet and in the init()
> >method
> >
> >we registered our listnerer.
> >The servlet was called on startup by Tomcat and we made sure to be
> >called *after* the OpenCms servlet.
> >
> >At least it was possible with OpenCms 5.0.
> >
> >Regards,
> >Thomas
> >
> >
> >
> >Best regards,
> >Andras Balogh.
> >
> >
> >
> >Small oversight on our part, this will be added ASAP.
> >
> >Best Regards,
> >Alex.
> >
> >Alexander Kandzior
> >Alkacon Software - The OpenCms Experts http://www.alkacon.com
More information about the opencms-dev
mailing list