Form delegateSubmit migration question

2014-11-09 Thread Maxim Solodovnik
Hello All, I'm trying to migrate project from Wicket 1.4 to Wicket 6. previously Form.delegateSubmit was Form.delegateSubmit( IFormSubmittingComponent http://ci.apache.org/projects/wicket/apidocs/1.4.x/org/apache/wicket/markup/html/form/IFormSubmittingComponent.html submittingComponent) and the

Re: Form delegateSubmit migration question

2014-11-09 Thread Francois Meillet
String inputName = ((FormComponent) submittingButton).getInputName(); François Meillet Formation Wicket - Développement Wicket Le 9 nov. 2014 à 13:08, Maxim Solodovnik solomax...@gmail.com a écrit : Hello All, I'm trying to migrate project from Wicket 1.4 to Wicket 6. previously

Re: Form delegateSubmit migration question

2014-11-09 Thread Maxim Solodovnik
Thanks for the quick response! Unfortunately this solution is not working due to: submittingButton instanceof org.apache.wicket.markup.html.form.FormComponent == false submittingButton instanceof org.apache.wicket.Component == false submittingButton instanceof submittingButton instanceof

Re: Form delegateSubmit migration question

2014-11-09 Thread Francois Meillet
What instanceof is this submittingButton ? François Meillet Formation Wicket - Développement Wicket Le 9 nov. 2014 à 13:42, Maxim Solodovnik solomax...@gmail.com a écrit : Thanks for the quick response! Unfortunately this solution is not working due to: submittingButton instanceof

Re: Form delegateSubmit migration question

2014-11-09 Thread Maxim Solodovnik
unfortunately I'm unable to guess :( submittingButton instanceof IFormSubmitter I'm out of ideas, this is why i wrote to the list :( On 9 November 2014 18:49, Francois Meillet francois.meil...@gmail.com wrote: What instanceof is this submittingButton ? François Meillet Formation Wicket -

Re: Form delegateSubmit migration question

2014-11-09 Thread Martin Grigorov
Hi, It is an anonymous instance - https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java#L159 And there is no way to get an inputName because it is not associated with IFormSubmittingComponent Why do you need the inputName ?

Re: Form delegateSubmit migration question

2014-11-09 Thread Maxim Solodovnik
In old code there was logic to perform different actions based on inputName :( On 9 November 2014 18:57, Martin Grigorov mgrigo...@apache.org wrote: Hi, It is an anonymous instance -

Re: Form delegateSubmit migration question

2014-11-09 Thread Maxim Solodovnik
Multi-submit button form, and the logic should be in onSubmit method but should be different based on button On 9 November 2014 19:00, Maxim Solodovnik solomax...@gmail.com wrote: In old code there was logic to perform different actions based on inputName :( On 9 November 2014 18:57, Martin

Re: Form delegateSubmit migration question

2014-11-09 Thread Martin Grigorov
I don't see a clean way how to accomplish what you need :-/ What I would try is to use the special variable this$0 via reflection to get a reference to the AjaxFormSubmitBehavior instance I see a way to simplify this code so it will be possible to do what you need: 1) AjaxFormSubmitBehavior

Re: Form delegateSubmit migration question

2014-11-09 Thread Maxim Solodovnik
Done: https://issues.apache.org/jira/browse/WICKET-5753 Thanks a lot Martin, will try to use the special variable this$0 via reflection On 9 November 2014 19:14, Martin Grigorov mgrigo...@apache.org wrote: I don't see a clean way how to accomplish what you need :-/ What I would try is to use

Re: Form delegateSubmit migration question

2014-11-09 Thread Maxim Solodovnik
one more thing: getComponent() is protected and not accessible :( On 9 November 2014 19:27, Maxim Solodovnik solomax...@gmail.com wrote: Done: https://issues.apache.org/jira/browse/WICKET-5753 Thanks a lot Martin, will try to use the special variable this$0 via reflection On 9 November 2014

Re: Form delegateSubmit migration question

2014-11-09 Thread Martin Grigorov
True. Another approach is to add getFormSubmittingComponent() to IFormSubmitter interface. But this is definitely only for 7.x. Did it work with this$0 ? Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Sun, Nov 9, 2014 at 3:52 PM, Maxim Solodovnik

Re: Form delegateSubmit migration question

2014-11-09 Thread Maxim Solodovnik
Yes, Thanks! currently adding another reflection call to get component :) On 9 November 2014 19:59, Martin Grigorov mgrigo...@apache.org wrote: True. Another approach is to add getFormSubmittingComponent() to IFormSubmitter interface. But this is definitely only for 7.x. Did it work with

Re: Form delegateSubmit migration question

2014-11-09 Thread Maxim Solodovnik
Somehow component field is not accessible via reflection: Field f = submittingButton.getClass().getDeclaredField(this$0); if (!f.isAccessible()) { f.setAccessible(true); } Object o = f.get(submittingButton); if (o instanceof AbstractAjaxBehavior) { AbstractAjaxBehavior aab =

Re: Form delegateSubmit migration question

2014-11-09 Thread Martin Grigorov
Use getField() instead On Nov 9, 2014 4:34 PM, Maxim Solodovnik solomax...@gmail.com wrote: Somehow component field is not accessible via reflection: Field f = submittingButton.getClass().getDeclaredField(this$0); if (!f.isAccessible()) { f.setAccessible(true); } Object o =

Re: Form delegateSubmit migration question

2014-11-09 Thread Maxim Solodovnik
aab.getClass().getField(component) NoSuchFieldException :( Debugger displays component field aab.getClass().getMethod(getComponent) NoSuchMethodException not sure what's happening On 9 November 2014 21:33, Martin Grigorov mgrigo...@apache.org wrote: Use getField() instead On Nov 9,

Re: Form delegateSubmit migration question

2014-11-09 Thread Martin Grigorov
AbstractAjaxBehavior.class.get[Declared]Field() On Nov 9, 2014 5:44 PM, Maxim Solodovnik solomax...@gmail.com wrote: aab.getClass().getField(component) NoSuchFieldException :( Debugger displays component field aab.getClass().getMethod(getComponent) NoSuchMethodException not sure

Re: Form delegateSubmit migration question

2014-11-09 Thread Maxim Solodovnik
Thanks! AbstractAjaxBehavior.class.getField(component) - fails AbstractAjaxBehavior.class.getDeclaredField(component) - works! Thanks a lot! On 9 November 2014 21:46, Martin Grigorov mgrigo...@apache.org wrote: AbstractAjaxBehavior.class.get[Declared]Field() On Nov 9, 2014 5:44 PM, Maxim