wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maxim Solodovnik <solomax...@gmail.com>
Subject Re: Form delegateSubmit migration question
Date Sun, 09 Nov 2014 15:44:02 GMT
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 <mgrigorov@apache.org> wrote:

> Use getField() instead
> On Nov 9, 2014 4:34 PM, "Maxim Solodovnik" <solomax666@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 = f.get(submittingButton);
> > if (o instanceof AbstractAjaxBehavior) {
> > AbstractAjaxBehavior aab = (AbstractAjaxBehavior)o;
> > Field inputf = aab.getClass().getDeclaredField("component");
> > inputName = ((IFormSubmittingComponent)inputf.get(o)).getInputName();
> > }
> >
> > results NoSuchFieldException in this:
> > Field inputf = aab.getClass().getDeclaredField("component");
> > line.
> >
> > seems to be dead-end :(
> >
> > On 9 November 2014 20:01, Maxim Solodovnik <solomax666@gmail.com> wrote:
> >
> > > Yes, Thanks!
> > > currently adding another reflection call to get component :)
> > >
> > > On 9 November 2014 19:59, Martin Grigorov <mgrigorov@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 this$0 ?
> > >>
> > >> Martin Grigorov
> > >> Wicket Training and Consulting
> > >> https://twitter.com/mtgrigorov
> > >>
> > >> On Sun, Nov 9, 2014 at 3:52 PM, Maxim Solodovnik <
> solomax666@gmail.com>
> > >> wrote:
> > >>
> > >> > one more thing: getComponent() is protected and not accessible :(
> > >> >
> > >> > On 9 November 2014 19:27, Maxim Solodovnik <solomax666@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 19:14, Martin Grigorov <mgrigorov@apache.org>
> > >> wrote:
> > >> > >
> > >> > >> 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 should implement IFormSubmitter
> > >> > >> 2) onEvent() should do:
> > getForm().getRootForm().onFormSubmitted(this)
> > >> > >>
> > >> > >> then you can cast to AbstractAjaxBehavior and call getComponent()
> > and
> > >> > then
> > >> > >> cast to IFormSubmittingComponent to get the input name
> > >> > >>
> > >> > >> I'm not sure whether clirr-maven-plugin will allow this change
in
> > 6.x
> > >> > >> though
> > >> > >>
> > >> > >> Please file a ticket and I'll take a look in the next days.
> > >> > >>
> > >> > >>
> > >> > >> Martin Grigorov
> > >> > >> Wicket Training and Consulting
> > >> > >> https://twitter.com/mtgrigorov
> > >> > >>
> > >> > >> On Sun, Nov 9, 2014 at 3:01 PM, Maxim Solodovnik <
> > >> solomax666@gmail.com>
> > >> > >> wrote:
> > >> > >>
> > >> > >> > 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 <
> solomax666@gmail.com
> > >
> > >> > >> wrote:
> > >> > >> >
> > >> > >> > > In old code there was logic to perform different
actions
> based
> > on
> > >> > >> > > inputName :(
> > >> > >> > >
> > >> > >> > >
> > >> > >> > > On 9 November 2014 18:57, Martin Grigorov <
> > mgrigorov@apache.org>
> > >> > >> wrote:
> > >> > >> > >
> > >> > >> > >> 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 ?
> > >> > >> > >>
> > >> > >> > >> Martin Grigorov
> > >> > >> > >> Wicket Training and Consulting
> > >> > >> > >> https://twitter.com/mtgrigorov
> > >> > >> > >>
> > >> > >> > >> On Sun, Nov 9, 2014 at 2:52 PM, Maxim Solodovnik
<
> > >> > >> solomax666@gmail.com>
> > >> > >> > >> wrote:
> > >> > >> > >>
> > >> > >> > >> > 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.meillet@gmail.com>
> > >> > >> > >> > wrote:
> > >> > >> > >> >
> > >> > >> > >> > > What instanceof is this submittingButton
 ?
> > >> > >> > >> > >
> > >> > >> > >> > > François Meillet
> > >> > >> > >> > > Formation Wicket - Développement
Wicket
> > >> > >> > >> > >
> > >> > >> > >> > >
> > >> > >> > >> > >
> > >> > >> > >> > >
> > >> > >> > >> > >
> > >> > >> > >> > > Le 9 nov. 2014 à 13:42, Maxim Solodovnik
<
> > >> solomax666@gmail.com
> > >> > >
> > >> > >> a
> > >> > >> > >> écrit
> > >> > >> > >> > :
> > >> > >> > >> > >
> > >> > >> > >> > > > 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
> > >> > >> > >> > > > org.apache.wicket.behavior.Behavior
== false
> > >> > >> > >> > > >
> > >> > >> > >> > > >
> > >> > >> > >> > > > On 9 November 2014 18:37, Francois
Meillet <
> > >> > >> > >> francois.meillet@gmail.com
> > >> > >> > >> > >
> > >> > >> > >> > > > wrote:
> > >> > >> > >> > > >
> > >> > >> > >> > > >> String inputName = ((FormComponent)
> > >> > >> > >> submittingButton).getInputName();
> > >> > >> > >> > > >>
> > >> > >> > >> > > >>
> > >> > >> > >> > > >> François Meillet
> > >> > >> > >> > > >> Formation Wicket - Développement
Wicket
> > >> > >> > >> > > >>
> > >> > >> > >> > > >>
> > >> > >> > >> > > >>
> > >> > >> > >> > > >>
> > >> > >> > >> > > >>
> > >> > >> > >> > > >> Le 9 nov. 2014 à 13:08,
Maxim Solodovnik <
> > >> > >> solomax666@gmail.com>
> > >> > >> > a
> > >> > >> > >> > > écrit :
> > >> > >> > >> > > >>
> > >> > >> > >> > > >>> 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 code:
> > >> > >> > >> > > >>> submittingComponent.getInputName()
worked as
> expected
> > >> > >> > >> > > >>> right now it is: Form.delegateSubmit(IFormSubmitter
> > >> > >> > >> submittingButton)
> > >> > >> > >> > > and
> > >> > >> > >> > > >>> it is impossible to
get inputName anymore :(
> > >> > >> > >> > > >>>
> > >> > >> > >> > > >>> I tried to cast submittingComponent
to
> > >> > >> IFormSubmittingComponent
> > >> > >> > >> but
> > >> > >> > >> > it
> > >> > >> > >> > > is
> > >> > >> > >> > > >>> not working due to submittingComponent
is of type
> > >> > >> > >> > > >>>
> > >> > >> "org.apache.wicket.ajax.form.AjaxFormSubmitBehavior$1@33b88671"
> > >> > >> > >> and
> > >> > >> > >> > > I'm
> > >> > >> > >> > > >>> unable to cast it to
something useful :(
> > >> > >> > >> > > >>>
> > >> > >> > >> > > >>> Thanks in advance!
> > >> > >> > >> > > >>>
> > >> > >> > >> > > >>> --
> > >> > >> > >> > > >>> WBR
> > >> > >> > >> > > >>> Maxim aka solomax
> > >> > >> > >> > > >>
> > >> > >> > >> > > >>
> > >> > >> > >> > > >
> > >> > >> > >> > > >
> > >> > >> > >> > > > --
> > >> > >> > >> > > > WBR
> > >> > >> > >> > > > Maxim aka solomax
> > >> > >> > >> > >
> > >> > >> > >> > >
> > >> > >> > >> >
> > >> > >> > >> >
> > >> > >> > >> > --
> > >> > >> > >> > WBR
> > >> > >> > >> > Maxim aka solomax
> > >> > >> > >> >
> > >> > >> > >>
> > >> > >> > >
> > >> > >> > >
> > >> > >> > >
> > >> > >> > > --
> > >> > >> > > WBR
> > >> > >> > > Maxim aka solomax
> > >> > >> > >
> > >> > >> >
> > >> > >> >
> > >> > >> >
> > >> > >> > --
> > >> > >> > WBR
> > >> > >> > Maxim aka solomax
> > >> > >> >
> > >> > >>
> > >> > >
> > >> > >
> > >> > >
> > >> > > --
> > >> > > WBR
> > >> > > Maxim aka solomax
> > >> > >
> > >> >
> > >> >
> > >> >
> > >> > --
> > >> > WBR
> > >> > Maxim aka solomax
> > >> >
> > >>
> > >
> > >
> > >
> > > --
> > > WBR
> > > Maxim aka solomax
> > >
> >
> >
> >
> > --
> > WBR
> > Maxim aka solomax
> >
>



-- 
WBR
Maxim aka solomax

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message