Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » How should I add validation to WindowBuilder-generated data binding?
How should I add validation to WindowBuilder-generated data binding? [message #893077] Mon, 02 July 2012 13:52 Go to next message
Alexey Romanov is currently offline Alexey Romanov
Messages: 263
Registered: May 2010
Senior Member
As far as I understand, to use JFace DataBinding validation, I need to use my own UpdateValueStrategy in dataBindingContext.bindValue(...) calls. But in case of WindowBuilder, these calls are made in generated initDataBinding() method which can't be edited by hand. So how should I do this?
Re: How should I add validation to WindowBuilder-generated data binding? [message #893329 is a reply to message #893077] Tue, 03 July 2012 14:48 Go to previous messageGo to next message
Eric Clayberg is currently offline Eric Clayberg
Messages: 873
Registered: July 2009
Location: Boston, MA
Senior Member
Are you saying that there is something you can't do using the provide Data Binding UI? You should provide a detailed example of what you are trying to do and illustrate why you think you need to modify the generated code.
Re: How should I add validation to WindowBuilder-generated data binding? [message #893337 is a reply to message #893329] Tue, 03 July 2012 15:23 Go to previous messageGo to next message
Alexey Romanov is currently offline Alexey Romanov
Messages: 263
Registered: May 2010
Senior Member
Let's take http://www.toedter.com/blog/?p=36 as an example. Note the call
dataBindingContext.bindValue(
    SWTObservables.observeText(firstNameText, SWT.Modify),
    PojoObservables.observeValue(person, "firstName"),
    new UpdateValueStrategy()
        .setAfterConvertValidator(new StringRequiredValidator(
             "Please enter first name",
              firstNameDecoration)),
    null);

where an UpdateValueStrategy is constructed manually.
So far as I've seen, UI only generates
new UpdateValueStrategy(UpdateValueStrategy.POLICY_XXX)

in initDataBindings() and doesn't let me customize it by setting validators or converters.

I also can't see a way to change the update strategy after the Binding is created in the API.
Re: How should I add validation to WindowBuilder-generated data binding? [message #893367 is a reply to message #893337] Tue, 03 July 2012 17:35 Go to previous messageGo to next message
Eric Clayberg is currently offline Eric Clayberg
Messages: 873
Registered: July 2009
Location: Boston, MA
Senior Member
Have you reviewed the WindowBuilder Data Binding docs? You can set validators and converters through the UI.

https://developers.google.com/java-dev-tools/wbpro/features/swt/data_binding/images/edit_binding_strategy_properties.gif

For anything too complex for the UI to handle, just write that code outside of the initDataBindings() method and have it run after initDataBindings() runs and the binding context has been created.
Re: How should I add validation to WindowBuilder-generated data binding? [message #893379 is a reply to message #893367] Tue, 03 July 2012 18:48 Go to previous message
Alexey Romanov is currently offline Alexey Romanov
Messages: 263
Registered: May 2010
Senior Member
Yes, I did, but apparently not carefully enough. Thanks!
Previous Topic:How to remove windowbuilder components?
Next Topic:text in button
Goto Forum:
  


Current Time: Fri Oct 31 10:15:48 GMT 2014

Powered by FUDForum. Page generated in 0.04192 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software