Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » [DataBinding] how to get the modified javabean property?
[DataBinding] how to get the modified javabean property? [message #312250] Mon, 05 February 2007 11:59 Go to next message
Eclipse UserFriend
Originally posted by: sudhakar.co.brazos.tx.us

I'm looking for examples on how to use JFace Databinding to persist
specific properties of a JavaBean.

I can access the JavaBean object in the handleBindingEvent(BindingEvent
e) method. But how do I determine which property was modified?

Here is my DataBindingContextFactory class.

public class DataBindingContextFactory {
public static DataBindingContext create(final Person person) {

DataBindingContext bindingContext = new DataBindingContext(
SWTObservables.getRealm(Display.getDefault()));

bindingContext.addBindingEventListener(new IBindingListener() {
public IStatus handleBindingEvent(BindingEvent e) {
if (e.copyType == BindingEvent.EVENT_COPY_TO_MODEL
&& e.pipelinePosition == BindingEvent.PIPELINE_AFTER_CHANGE) {
// how to determine what property was changed?
return Status.OK_STATUS;
}
});

return bindingContext;
}
}

Thanks
-sud
Re: [DataBinding] how to get the modified javabean property? [message #312261 is a reply to message #312250] Mon, 05 February 2007 14:05 Go to previous messageGo to next message
Eclipse UserFriend
I recently added a mixin interface that provides this for java bean
observables. I'm not sure what version of data binding you're using but
look for IBeanObservable. If that exists you should be able to cast your
model observable to this interface. IBeanObservable exposes the observed
object and the PropertyDescriptor.

-brad
Re: [DataBinding] how to get the modified javabean property? [message #312267 is a reply to message #312261] Mon, 05 February 2007 15:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sudhakar.co.brazos.tx.us

My databinding code looks like below:

bindingContext.bindValue(SWTObservables.observeText(lastName Text,SWT.FocusOut),BeansObservables.observeValue(person, "sn"),null);

I have the following code in my handleBindingEvent(BindingEvent e) method:

IBeanObservable bean = (IBeanObservable) e.getSource();
PropertyDescriptor prop = bean.getPropertyDescriptor();

I don't think I'm doing this right. The e.getSource() doesn't get me the
bean. So I can't get to the property that was modified.

Thanks in advance for any help.

-sud



Brad Reynolds wrote:
> I recently added a mixin interface that provides this for java bean
> observables. I'm not sure what version of data binding you're using but
> look for IBeanObservable. If that exists you should be able to cast
> your model observable to this interface. IBeanObservable exposes the
> observed object and the PropertyDescriptor.
>
> -brad
>
Re: [DataBinding] how to get the modified javabean property? [message #312271 is a reply to message #312267] Mon, 05 February 2007 17:33 Go to previous messageGo to next message
Eclipse UserFriend
It looks like in the sanity pass for 3.3M5 the API that you needed was
accidentally removed. As of a minute ago this is back in[1] and will be
in 3.3M5. What you need to do in your binding listener is to retrieve the
binding from the event and get the model from the binding. Then cast the
model observable to IBeanObservable and you should have what you need.

-brad

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=172946
Re: [DataBinding] how to get the modified javabean property? [message #312273 is a reply to message #312271] Mon, 05 February 2007 18:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sudhakar.co.brazos.tx.us

Thank you!

That was it. Appreciate all the work you are doing in the DataBinding
area. It is helping simplify a lot of our work.

-sud

Brad Reynolds wrote:
> It looks like in the sanity pass for 3.3M5 the API that you needed was
> accidentally removed. As of a minute ago this is back in[1] and will be
> in 3.3M5. What you need to do in your binding listener is to retrieve
> the binding from the event and get the model from the binding. Then
> cast the model observable to IBeanObservable and you should have what
> you need.
>
> -brad
>
> [1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=172946
>
Re: [DataBinding] how to get the modified javabean property? [message #312282 is a reply to message #312273] Mon, 05 February 2007 19:07 Go to previous message
Eclipse UserFriend
sudhakar wrote:

> Thank you!

> That was it. Appreciate all the work you are doing in the DataBinding
> area. It is helping simplify a lot of our work.

Glad to hear it. Thanks for pointing out this issue. 3.3M5 could have
been bad for Data Binding. :)

-brad
Previous Topic:Eclipse on Solaris???
Next Topic:[DataBinding] How to validate and bind logic between 2 or more values ?
Goto Forum:
  


Current Time: Sun Jul 27 16:21:03 EDT 2025

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

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

Back to the top