[Databinding] Editor (isDirty), PojoObservable and ChangeListener on target to [message #330999] |
Wed, 20 August 2008 20:45 |
|
Hi,
I have an editor which uses Databinding. The model is a Pojo hence I'm
using PojoObservable.
To set the Editor dirty I try to register ChangeListener on the bindings.
IObservableList bindings = bindingContext.getBindings();
for (Iterator<Binding> iterator = bindings.iterator();
iterator.hasNext();) {
Binding object = iterator.next();
object.getTarget().addChangeListener(new IChangeListener() {
public void handleChange(ChangeEvent event) {
firePropertyChange(IEditorPart.PROP_DIRTY);
}
});
}
As it seems this ChangeListener is called before the model is updated.
Therefore my isDirty check doesn't find changes in the model and doesn't
set the editor to isDirty. The second change then flags the editor as dirty.
Is there a way around this or do I have to change my model from Pojos to
JavaBeans with PropertyChangeListeners?
Best regards, Lars
|
|
|
Re: [Databinding] Editor (isDirty), PojoObservable and ChangeListener on target to [message #331000 is a reply to message #330999] |
Wed, 20 August 2008 20:51 |
|
Sorry, forget the question. Registering my changeListener to the model
works. PojoObserable also has change support.
Lars Vogel wrote:
> Hi,
>
> I have an editor which uses Databinding. The model is a Pojo hence I'm
> using PojoObservable.
>
> To set the Editor dirty I try to register ChangeListener on the bindings.
>
> IObservableList bindings = bindingContext.getBindings();
> for (Iterator<Binding> iterator = bindings.iterator();
> iterator.hasNext();) {
> Binding object = iterator.next();
> object.getTarget().addChangeListener(new IChangeListener() {
> public void handleChange(ChangeEvent event) {
> firePropertyChange(IEditorPart.PROP_DIRTY);
> }
> });
> }
>
> As it seems this ChangeListener is called before the model is updated.
> Therefore my isDirty check doesn't find changes in the model and doesn't
> set the editor to isDirty. The second change then flags the editor as
> dirty.
>
> Is there a way around this or do I have to change my model from Pojos to
> JavaBeans with PropertyChangeListeners?
>
> Best regards, Lars
>
|
|
|
Powered by
FUDForum. Page generated in 0.02937 seconds