0

EventQueue unsubscribe problem

asked 2010-04-14 05:16:55 +0800

ryanwong00 gravatar image ryanwong00
63 1

Hi Everyone,

I am a newbie trying to implement a multilingual application. I created a combobox for user to select language option.
Whenever a language is selected, all labels/buttons on the screen will change the language immediately. The mechanism I am using is as following:
1. Create an EventQueue (e.g. EventQueues.lookup("change", EventQueues.DESKTOP, true);
2. All components defined in zul will be constructed by GenericForwardComposer. Within the doAfterCompose method, an eventlistener listening to EventQueue created at step 1 will be created. Thus, whenever a language is selected, all components will be notified and change labels accordingly.

My problem is : if a containers (e.g. Tabs/Windows) is closed , all its children/subchild/sub-subchild will still be attached to the EventQueue and will never be garbage collected. Is there any way to close all child/subchild component through programs? Or, is there any alternative to create such kind of multilingual application?

Thanks
Ryan :-(

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2010-04-15 01:17:26 +0800

SimonPai gravatar image SimonPai
1696 1

Ryan,

ZK has a way to support i18n naturally. Here is the reference.

Regards,
Simon

link publish delete flag offensive edit

answered 2010-04-15 01:33:21 +0800

ryanwong00 gravatar image ryanwong00
63 1

Hi Simon,

Thanks for your reply.
I have tried the standard approach before.
However, with the standard approach, when user choose a different language, I have to refresh the whole page to make it take effect.
The effect I am looking for is : once a user choose a different language, all labels/button will change the language automatically without refreshing the page.
Is there any way to do it ?

Thanks
Ryan :-)

link publish delete flag offensive edit

answered 2010-04-19 07:04:04 +0800

PeterKuo gravatar image PeterKuo
481 2

@ryanwong00

Do you accept
Change locale info,
Redirect to the same page by server?

link publish delete flag offensive edit

answered 2010-04-21 01:55:32 +0800

ryanwong00 gravatar image ryanwong00
63 1

updated 2010-04-21 01:56:51 +0800

Hi Peter,

Thanks for your suggestion. However, that approach might not be appropiate for my situation since our existing customer has already got used to the effect I mentioned (i.e. implemented in Swing). However, I have figured out how to achieve the effect :
1. Create an interface e.g. ComponentIF with a method reloadLocale
2. Extend existing Zk components with additional attributes (e.g. labelKey, tooltipkey ... for Button, Tab) and implemented ComponentIF.
3. Amend all zuls to point to my version of components (e.g. ?component name="window" extends="window" class="a.b.c.Window"?>)
4. Whenever user selected a different language, call comp.getDesktop() and then iterate over all its components (i.e. desktop.getComponents()) . For each components, if it is an instance of ComponentIF, simply call reloadLocale to force it to reload the labels by using attributes defined in step 2.

Up to this moment, the effect of this approach works quite well.
However, I am still looking for a way to change the css class of the component immediately since difference language may require different appearance (i.e. Can I enforce a component to look at a different css and change its appearance immediately?)

Thanks a lot
Ryan :-)

link publish delete flag offensive edit

answered 2010-04-23 03:53:58 +0800

PeterKuo gravatar image PeterKuo
481 2

I think setSclass should work as you like.

http://www.zkoss.org/javadoc/3.5.2/zk/org/zkoss/zk/ui/api/HtmlBasedComponent.html#setSclass%28java.lang.String%29

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-04-14 05:16:55 +0800

Seen: 385 times

Last updated: Apr 23 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More