0

ZK & Spring Bean

asked 2009-01-15 15:22:22 +0800

lamh gravatar image lamh
84 3

Question 1:
In Zk, I want to use org.zkoss.zkplus.spring.DelegatingVariableResolver to bind spring bean. If the session is serialized, would the spring bean be serialized as well?

Question 2:
Zk uses i3 properties for localization. I use spring's messageSource to load up a list of property files (i.e. message_en.properties, message_fr.properties, error_en.properties, error_fr.properties......)

Is it possible to configure Zk to
1: use spring's messageSource
2: specify a list of property files for Zk to use, instead of the i3 properties.

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2009-01-16 04:20:30 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

updated 2009-01-16 04:21:27 +0800

For doing custom internalization ,
check here http://docs.zkoss.org/wiki/Internationalization#Labels,
last paragraph in this session:
"In addition, you could extend the label loader to load labels from other locations, say database, by registering a locator, which must implement the org.zkoss.util.resource.LabelLocator interface. Then, invoke the register method of the org.zkoss.util.resource.Labels class."

link publish delete flag offensive edit

answered 2009-01-16 20:57:58 +0800

lamh gravatar image lamh
84 3

I looked at the LabelLoader class and LabelLocator interface. It looks like registering the locator must be done before any prior access to getLabel(String key). Otherwise, only i3 properties will be loaded.

I suppose I can do registering in some sort of initialization servlet.

Any other suggestions?

link publish delete flag offensive edit

answered 2009-01-17 10:27:24 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

you can do it in your servlet or register some listener of ZK in zk.xml , both OK I think.

link publish delete flag offensive edit

answered 2009-01-17 14:50:13 +0800

jtoupin gravatar image jtoupin
156

updated 2009-01-17 14:52:04 +0800

I'm also using Spring's MessageSource. I create a LocalizationManager class which I register as a been with id 'lm'. Then I use MVEL expressions instead of standard EL. This way I can do the following in my zul files:

<label value="${lm.getMessage("message.key")}" />

or:

<label value="${lm.getMessage('amount.earned.message', 5.36)}" />

if I have a parameter.

To use MVEL, add the following to the beginning of your zul page:

<?evaluator name="mvel"?>

I have not yet found a way to set it application wide in zk.xml.

link publish delete flag offensive edit

answered 2009-01-19 01:19:16 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

did you set this in page?
<?variable-resolver class="org.zkoss.zkplus.seasar.DelegatingVariableResolver"?>

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: 2009-01-15 15:22:22 +0800

Seen: 382 times

Last updated: Jan 19 '09

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