Just an example of what can be achieved with the new feature, with a
little coding i can atach generic listeners in a declarative way to
components in sdl, for example:
table ID="entityList" do="saludar" event:doubleClicked="extractRecord"
With this code i can make my jtable to invoque the extractrecord
method of the controller when one row is double clicked, and the best
thing is that i can attach any method like the do option for buttons
as listener and even specify the listener type :)
To do that i only need this java code:
UI.registerPropertyHandler("event", new ComponentPropertyHandler() {
@Override
public void set(final Component component, String key, final Object
value)
throws UIBindingException {
if (key.equalsIgnoreCase("doubleClicked")) {
component.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
FormController controller = UI
.getFormForComponent(component)
.getController();
try {
Method m = controller.getClass()
.getDeclaredMethod(value.toString(),
new Class[] {});
m.invoke(controller, new Object[] {});
} catch (Exception e1) {
throw new UIBindingException("Problem trying to execute
method "+value+"as double click listener for "+component.getName(),
e1);
}
}
}
});
}
}
});
Using the key value i can attach other type of listeners if needed,
the code may seem complicated but it´s not, it´s due to the use of
nested clases, i wonder if i could use Scala or Groovy to make it even
more readable. :)
Anyway, thanks a lot again for the new feature, Dan