0

Of attributes, data binding and type converters

asked 2008-08-29 12:59:04 +0800

dastultz gravatar image dastultz
797 9

I have the following "resource" that I use to simplify my binding code so I don't need to specify the attribute for the most common case.

public static final HashMap<Class, String> componentBindingAttributes = new HashMap<Class, String>();
static {
componentBindingAttributes.put(Listbox.class, "selectedItem"); // todo: see if this information exists in zk
componentBindingAttributes.put(Combobox.class, "selectedItem");
componentBindingAttributes.put(Checkbox.class, "checked");
componentBindingAttributes.put(Button.class, "label");
}

Then I use it like so:

String attribute = componentBindingAttributes.get(component.getClass());
if (attribute == null) attribute = "value";
binder.addBinding(component, attribute, expression);

I am wondering if I am duplicating any such feature in Zk. Is this sort of information, a "common binding attribute list" available?

Also, I noticed that when I do not specify a type converter for a list box, the proper type converter is chosen. I have a subclass of list box and I would like to "register" the proper type converter to be used with my subclass so I do not need to specify it every time. Also, the "natural" access value for label is "load" while the "natural" access value for listbox is "both". I would like to register the natural access value for my list box subclass as well.

Thanks.

/Daryl

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2008-09-02 07:56:28 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

take a look of the lang-addon.xml in zkplus.jar.

link publish delete flag offensive edit

answered 2008-09-02 13:00:12 +0800

dastultz gravatar image dastultz
797 9

That solves the second part for converter and access. I'm guessing since there are more than one "default-bind" for some components there probably is no default property to bind to such as "value" for datebox and "label" for button. Maybe this just the way I will be using the framework...

Thanks.

/Daryl

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: 2008-08-29 12:59:04 +0800

Seen: 503 times

Last updated: Sep 02 '08

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