sorry for my english. This is great project, but I have little problem with rebinding of action button. In my project, every domain object is inspected with setToInspect method firstly and then with rebind method. Every domain class has one @UiAction annotated method called “Save”. The problem is that action button is not rebinding to new instance / domain object, but remains bound to firstly inspected object with setToInspect method. This behaviour is not appropriate, because the program tries to save firstly bound object, although there is another object same type displayed / bound in metawidget form.
This is sort of a bug, but sort of not. Here's what's happening:
BeansBindingProcessor works with BeansBinding. And BeansBinding only binds properties. It has no support for binding methods (as far as I know?). So BeansBindingProcessor has nothing to do with button clicks.
ReflectionBindingProcessor binds button clicks using standard Java reflection
Re-binding is a useful shortcut, offered by BeansBindingProcessor, for when your object changes but it's structure is identical to a previous object
So what you're really asking for is a 'ReflectionBindingProcessor.rebind' method. But 'rebind' only makes sense for BeansBindingProcessor because BeansBindingProcessor also has a 'save' method. There is no 'ReflectionBindingProcessor.save'.
Rather than rebinding, you can just do a full re-inspection. You can just call 'smw.setToInspect( myNewObject )' and everything will get rebuilt. This is the cleanest solution. And, indeed, this is what you are (accidentally) triggering when you are manipulating the widgetprocessors list.
Is a full re-inspection too expensive for you?
Regards,
Richard.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you look at the code for SwingMetawidget.java you'll see a number of
methods (including add/removeWidgetProcessor) call 'invalidateWidgets'
which triggers a full re-inspection. So for example if you call
'setReadOnly(true)' Metawidget will trigger a full rebuild with read-only
widgets.
It is my fault you missed my post, because I posted it like new post, not like answer.
I looked at SwingMetawidget.java code and saw two things.
The method named setReadOnly looks like methods add/removeWidgetProcessor, it calls invalidateWidgets method. So the method setReadOnly is not much better than others two and let's call them 3M.
But there is another invalidate method named invalidateInspection and I understood (hopefully correct) there are three possibilities of metawidget building/using:
inspection + widget building, using setToInspect method
widget building, using 3M methods
rebinding, without 3M methods
Is it correct? Of course the best one is the third one, but without 3M methods there is not action button rebinding, so I have to be satisfied with the second case, which is better than first.
Regards,
Milky
Last edit: milky 2013-01-22
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It is my fault you missed my post, because I posted it like new post, not
like answer.
I looked at SwingMetawidget.java code and saw two things.
-
The method named setReadOnly looks like methods
add/removeWidgetProcessor, it calls invalidateWidgets method. So the method
setReadOnly is not much better than others two and let's call them 3M.
-
But there is another invalidate method named invalidateInspection and
I understood (hopefully correct) there are three possibilities of
metawidget building:
1. inspection + widget building, with setToInspect method
2. widget building, with 3M methods
3. rebinding, without 3M methods
Is it correct? Of course the best one is the third one, but without 3M
methods there is not action button rebinding, so I have to be satisfied
with the second case, which is better than first.
(find the latest version of the metawidget-all-*.jar)
Could you please try it and confirm it works for you?
Regards,
Richard.
On 23/01/2013 9:15 AM, Kennard Consulting wrote:
Ah, I see what you're saying. Sorry for not understanding sooner. I am away
on holiday so have limited code access!
You are correct. I will add a 'rebind' method to ReflectionBindingProcessor
for you over the next couple days. Thanks for your patience.
Regards,
Richard
On 2013-01-23 12:21 AM, "milky" milky945@users.sf.net milky945@users.sf.net wrote:
Hi Richard
It is my fault you missed my post, because I posted it like new post, not
like answer.
I looked at SwingMetawidget.java code and saw two things.
-
The method named setReadOnly looks like methods
add/removeWidgetProcessor, it calls invalidateWidgets method. So the method
setReadOnly is not much better than others two and let's call them 3M.
-
But there is another invalidate method named invalidateInspection and
I understood (hopefully correct) there are three possibilities of
metawidget building:
1. inspection + widget building, with setToInspect method
2. widget building, with 3M methods
3. rebinding, without 3M methods
Is it correct? Of course the best one is the third one, but without 3M
methods there is not action button rebinding, so I have to be satisfied
with the second case, which is better than first.
Regards,
Milky
-----------------------------------------------------------------------------------------------------------------------------------------------------------
rebind action button with @UiActionhttps://sourceforge.net/p/metawidget/discussion/747623/thread/0fe8883c/?limit=25#b0c2/8d94/0d94/cb18
Sent from sourceforge.net because you indicated interest in
https://sourceforge.net/p/metawidget/discussion/747623/
To unsubscribe from further messages, please visit
https://sourceforge.net/auth/prefs/
Thank you for your prompt answer. You guessed right that I need to do something like 'ReflectionBindingProcessor.rebind' with effect on form buttons.
I am a little bit confused. You wrote I am accidentally triggering full metawidget rebuild like setToInspect method does. I dont understand why. In my solution, I am only removing and adding instance of ReflectionBindingProcessor, which is responsible for Action binding. Besides, the response / speed of “building” metawidget is still different for both cases, the rebind method is faster than setToInspect method.
To answer your question, full re-inspection is and is not too expensive for me. But I would rather choose shorter path, with rebinding. So once again, this is my rebind code, which rebinds properties and action button also:
private void rebindMetaWidget(SwingMetawidget smw, DBase mymodel) {
if (smw != null) {
smw.getWidgetProcessor(BeansBindingProcessor.class).rebind(mymodel, smw);
smw.removeWidgetProcessor(smw.getWidgetProcessor(ReflectionBindingProcessor.class));
smw.addWidgetProcessor( new ReflectionBindingProcessor());
}
}
and this is part of my setToInspect code (only adding, not removing of widgetProcessor):
smw.addWidgetProcessor( new ReflectionBindingProcessor());
Regards,
Milky
Last edit: milky 2013-01-18
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi folks,
sorry for my english. This is great project, but I have little problem with rebinding of action button. In my project, every domain object is inspected with setToInspect method firstly and then with rebind method. Every domain class has one @UiAction annotated method called “Save”. The problem is that action button is not rebinding to new instance / domain object, but remains bound to firstly inspected object with setToInspect method. This behaviour is not appropriate, because the program tries to save firstly bound object, although there is another object same type displayed / bound in metawidget form.
The code used for rebinding:
Is the problem on the framework side or on my code side? I tried to find solution, but could not find any.
Thanks for help,
Milky
Last edit: milky 2013-01-15
Seems i found the solution. I added next line of code for both types of insection*, for setToInspect and rebind.
I dont know if repeated adding of widgetProcessor into one metawidget is right solution. So i added before addWidgetProcessor anoteher line of code:
Is this right solution?
*Of course there is only one type of inspection, namely setToInspect, the other one is not, but i called it for myself.
Last edit: milky 2013-01-15
Hi Milky,
Thanks for your interest in Metawidget!
This is sort of a bug, but sort of not. Here's what's happening:
So what you're really asking for is a 'ReflectionBindingProcessor.rebind' method. But 'rebind' only makes sense for BeansBindingProcessor because BeansBindingProcessor also has a 'save' method. There is no 'ReflectionBindingProcessor.save'.
Rather than rebinding, you can just do a full re-inspection. You can just call 'smw.setToInspect( myNewObject )' and everything will get rebuilt. This is the cleanest solution. And, indeed, this is what you are (accidentally) triggering when you are manipulating the widgetprocessors list.
Is a full re-inspection too expensive for you?
Regards,
Richard.
Hi Richard, please look at my (next) post, which I wrote 6 days ago.
Last edit: milky 2013-01-21
Apologies I missed your reply.
If you look at the code for SwingMetawidget.java you'll see a number of
methods (including add/removeWidgetProcessor) call 'invalidateWidgets'
which triggers a full re-inspection. So for example if you call
'setReadOnly(true)' Metawidget will trigger a full rebuild with read-only
widgets.
Can you confirm this is what you're seeing?
Regards,
Richard
On 2013-01-21 11:14 PM, "milky" milky945@users.sf.net wrote:
Hi Richard
It is my fault you missed my post, because I posted it like new post, not like answer.
I looked at SwingMetawidget.java code and saw two things.
The method named setReadOnly looks like methods add/removeWidgetProcessor, it calls invalidateWidgets method. So the method setReadOnly is not much better than others two and let's call them 3M.
But there is another invalidate method named invalidateInspection and I understood (hopefully correct) there are three possibilities of metawidget building/using:
Is it correct? Of course the best one is the third one, but without 3M methods there is not action button rebinding, so I have to be satisfied with the second case, which is better than first.
Regards,
Milky
Last edit: milky 2013-01-22
Ah, I see what you're saying. Sorry for not understanding sooner. I am away
on holiday so have limited code access!
You are correct. I will add a 'rebind' method to ReflectionBindingProcessor
for you over the next couple days. Thanks for your patience.
Regards,
Richard
On 2013-01-23 12:21 AM, "milky" milky945@users.sf.net wrote:
Milky,
Okay this is now checked in and available under:
https://repository.jboss.org/nexus/content/repositories/snapshots/org/metawidget/modules/metawidget-all/3.0-SNAPSHOT
(find the latest version of the metawidget-all-*.jar)
Could you please try it and confirm it works for you?
Regards,
Richard.
On 23/01/2013 9:15 AM, Kennard Consulting wrote:
Hi Richard
Thank you for your prompt answer. You guessed right that I need to do something like 'ReflectionBindingProcessor.rebind' with effect on form buttons.
I am a little bit confused. You wrote I am accidentally triggering full metawidget rebuild like setToInspect method does. I dont understand why. In my solution, I am only removing and adding instance of ReflectionBindingProcessor, which is responsible for Action binding. Besides, the response / speed of “building” metawidget is still different for both cases, the rebind method is faster than setToInspect method.
To answer your question, full re-inspection is and is not too expensive for me. But I would rather choose shorter path, with rebinding. So once again, this is my rebind code, which rebinds properties and action button also:
and this is part of my setToInspect code (only adding, not removing of widgetProcessor):
Regards,
Milky
Last edit: milky 2013-01-18
Metawidget 3.0, which includes this fix, has now been released. I'd be most grateful if you could download it and confirm it works for you.
Regards,
Richard.