AW: AW: [opencms-dev] Missing element that calls a customizedEventListener

Bernd Wolfsegger bw at code-create.com
Tue Mar 29 12:32:44 CEST 2005


Hi Martin,

On Tuesday 29 March 2005 11:18, Martin Lehnert wrote:
>
> Yes, I mean the FlexCache. If I save the language-decision only as an
> attribute in the session, the FlexCache will have no possibility to
> distinguish between different language versions. Am I wrong there?

It checks not the session, but it checks the locale setting in the opencms 
request. And that is set by your customized LocaleHandler. So you just have 
to add "locale" to your cache property. In my case it is set to: uri;locale

> As far 
> as I know the FlexCache can check parameters in the Url, but not the
> session. I have static content that I would like to show in different
> language versions. So I want them being cached of course, because the
> content is not dynamically generated, just distinguished by language.

What do you mean?
If the content is served by the OpenCms Database it is generated somehow. :)
And the language decision is also dynamically as is the content grabbing form 
the database in the correct language.
You use one document for all languages? If you have different static documents 
in different languages, there should be no problem at all and you would need 
no Localhandler.

>
> > And how do you decide what Language to use?
> > If you do it with a parameter in the url, the urls are not identically,
>
> and everytime you change language, e.g. > by a click on a button, the new
> decision will be saved in the session. If you decide depending on the top
> level > domain, the urls are not identical too, and changing the top level
> domain will also store the new decision into > the session. But for
> different top level domains there will be different sessions anyway.
>
> The user can decide at the start-page by clicking on the language-version
> that he likes. This would save the matching attribute in his session. This
> would not generate different URLs. Of course I could save the decision also
> as a parameter in the URL, but that would not make it a "different" Url, at
> least not "different enough" for analysis programs.

Yeah, but thats enough, when you save it in the session and construct the 
appropiate CmsI18nInfo object with the appropiate Locale value in your 
customized Handler. With cache set to "locale" as mentioned above, flex will 
save different variations for each language.

>
> > Again, there is the parameter in the url everytime you change the
>
> language, so all subsequent request made for > the same user are in the
> same language until the next appereance of the parameter.
>
> > And using top level domains you can recognize it depending on the domain.
>
> If the parameter appears only once when changing the language version, how
> should the FlexCache decide which language-version of a page to present at
> the hits between changes of the language version? Or did I get you wrong?

Well, thas what YOU are doing in the customized Handler.
You pick the value from the session, it is saved there, and construct the 
CmsI18nInfo object. Than flex and opencms knows which Locale to use.

>
> > I don't understand.
> > I use the Flex Cache and all works fine. The German pages are cached
>
> separately from the English ones.
>
> My mistake. I wanted to say: The session based stuff works only when
> cookies are enabled, so the entire page would only work when cookies are
> enabled, and that is a presumption that is not acceptable for my client. Of
> course I need some way to store information for forms, user-dependencies
> and stuff, and that is accepted. But he does not want to have cookies
> enabled just for showing static content in two different language versions.

You don't need cookies for session handling. But you have to provide the 
sessionid in the URL than, for each generated url on your site.
And that may be is a problem at the current state of OpenCms, because it may 
be difficult to get the sessionid from the request into the generated urls, 
if it is not done automatically by opencms if cookies are disabled.

>
> Nevertheless, thank you very much for this discussion. There is no way
> better for learning details than by having a good discussion about them.
> :-)

Exactly :)

Regards, Bernd

>
> Greetings,
>
> Martin Lehnert
> Hannecke IT-Solutions GmbH
> Martin-Luther-Str. 5b
> 97072 Würzburg
> Tel.: 0931-99 135 24
> 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
> > >
> > > _______________________________________________
> > > This mail is send to you from the opencms-dev mailing list To change
> > > your list options, or to unsubscribe from the list, please visit
> > > http://mail.opencms.org/mailman/listinfo/opencms-dev

-- 

[  Code Create
[  Information Technology & Architecture


[  Bernd Wolfsegger

[  Sun Certified Programmer for Java(TM) 2 Platform
[  Dipl.-Ing. Architekt

[  Office in Germany
[
[  Lohmeyerstrasse 13
[  10587 Berlin
[  Germany
[  +49 (0)30 26555788

[  Office in Kenya
[
[  P.O. Box 890
[  V/Market
[  00621 Nairobi
[  Kenya
[  +254 (0)720 481053

[  bw at code-create.de(com)
[  http://www.code-create.de(com)/




More information about the opencms-dev mailing list