0

Why was the default constructor for DelegatingVariableResolver changed? (ZK 5.0.3)

asked 2010-07-01 02:12:44 +0800

tomCat gravatar image tomCat
276 3

Hi ZK Team,

in the new ZK release (5.0.3) the default constructor for the DelegatingVariableResolver was changed from an empty
constrcutor to:

public DelegatingVariableResolver() {
		final Configuration conf = Executions.getCurrent().getDesktop()
				.getWebApp().getConfiguration();
		final String value = conf.getPreference("org.zkoss.spring.VariableResolver",
				null);
		if (value != null) {
			String[] vrClss = value.split(",");
			for (int i = 0; i < vrClss.length; i++) {
				try {
					Object o = Classes.newInstanceByThread(vrClss<i >);
					if(!_variableResolvers.contains(o)) {
						_variableResolvers.add(o);
					}
				} catch (Exception e) {
					// do nothing
				}
			}
		} else {
			_variableResolvers.add(new DefaultDelegatingVariableResolver());
		}

	}

With this new implementation you can not create an instance of DelegatingVariableResolver outside of a zk execution. For example: I am using an instance of DelegatingVariableResolver inside my SimpleUiFactory to attach a VariableResolver to all my pages:

public class DelegatingVariableResolverSerializableUiFactory 
	extends SimpleUiFactory {

	private static final String SECURITY_TLD_URL = "";
	
	private final FunctionMapper functionMapper;
	private final VariableResolver variableResolver;

	public DelegatingVariableResolverSerializableUiFactory() throws XelException, MalformedURLException {
		// init taglibMapper
		TaglibMapper taglibMapper = new TaglibMapper();
		taglibMapper.load("sec", new URL(SECURITY_TLD_URL));
		functionMapper = taglibMapper;
		
		// init VariableResolver
		variableResolver = new DelegatingVariableResolver();
	}

        // more methods here...
}

I am creating the VariableResolver inside the constructor of my SimpleUiFactory, cause i want all pages to use the same VariableResolver. So why are you now expecting a ZK execution inside the constructor of the DelegatingVariableResolver (5.0.3)?

Perhaps something like this would also work:

public DelegatingVariableResolver() {
		Configuration conf = null;
		String value = null;

                try {
                          conf = Executions.getCurrent().getDesktop()
				.getWebApp().getConfiguration();
		          value = conf.getPreference("org.zkoss.spring.VariableResolver",
				null);
                } catch (Exception e) {
                   // error handling
                }

                ...
}

Best regards,

tom

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2010-07-01 22:23:33 +0800

ashishd gravatar image ashishd flag of Taiwan
1972 6

Hi tomCat,
You are right. Current implementation of DelegatingVariableResolver can not support your use case. I have posted this as a bug to ZK tracker and it will be fixed soon. Thanks for pointing it out.

link publish delete flag offensive edit

answered 2010-08-16 19:58:20 +0800

tomyeh gravatar image tomyeh
610 1 3
http://blog.zkoss.org ZK Team

It is a feature rather than a bug. I posted and implemented it. Refer here.

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-07-01 02:12:44 +0800

Seen: 312 times

Last updated: Aug 16 '10

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