You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Gerolf Seitz <ge...@gmail.com> on 2007/12/20 03:41:25 UTC

Refactor IFormSubmittingComponent to enhance FormTester

Hi folks,

FormTester#submit(String) takes a buttonComponentId for submitting the Form
with an alternate button.
in #setValue, the corresponding Component is cast to a FormComponent. this
makes it impossible to pass the id of
a SubmitLink to #submit(String).
#setValue only calls getInputName on the formComponent. the same method
happens to be declared in
IFormSubmittingComponent (IFSC) (which is implemented by AbstractSubmitLink)

the idea is the following:
+ create a new interface IFormComponent
+ move the methods IFSC#getInputName and IFSC#getForm to IFormComponent
+ let IFSC extend IFormComponent
+ let FormComponent implement IFormComponent
+ let FormTester#setValue cast to IFormComponent instead of FormComponent

this way, there's no API break, but FormTester can use
IFormSubmittingComponents too.

wdyt?

  Gerolf


P.S.: suggestions for a better name than IFormComponent are much
appreciated.

Re: Refactor IFormSubmittingComponent to enhance FormTester

Posted by Gerolf Seitz <ge...@gmail.com>.
On Dec 20, 2007 9:12 AM, Johan Compagner <jc...@gmail.com> wrote:

> I am afraid if you create a iformcomponent that then those 2 methods
> are not enough an people start to expect that the can just randomly
> create a component implement the interface and they are done..
>
> So for such an interface to exist then it also really have to be used
> every where and not just in our testing part.
>

something similar came to my mind after i have slept over it.
and, if there's getInputName, there should probably also be getInput
(because what good
is the inputName if you can't access the input itself).


>
> What i would do is just check in the tester with instanceof and cast
> to what it finds
>

that's also what Matej suggested in the first place (last night in
##wicket).
i thought there might be a more elegant solution, but it's probably not
worth it.

i will take the instanceof way then...(if nobody objects)

  Gerolf


>
> On 12/20/07, Gerolf Seitz <ge...@gmail.com> wrote:
> > Hi folks,
> >
> > FormTester#submit(String) takes a buttonComponentId for submitting the
> Form
> > with an alternate button.
> > in #setValue, the corresponding Component is cast to a FormComponent.
> this
> > makes it impossible to pass the id of
> > a SubmitLink to #submit(String).
> > #setValue only calls getInputName on the formComponent. the same method
> > happens to be declared in
> > IFormSubmittingComponent (IFSC) (which is implemented by
> AbstractSubmitLink)
> >
> > the idea is the following:
> > + create a new interface IFormComponent
> > + move the methods IFSC#getInputName and IFSC#getForm to IFormComponent
> > + let IFSC extend IFormComponent
> > + let FormComponent implement IFormComponent
> > + let FormTester#setValue cast to IFormComponent instead of
> FormComponent
> >
> > this way, there's no API break, but FormTester can use
> > IFormSubmittingComponents too.
> >
> > wdyt?
> >
> >   Gerolf
> >
> >
> > P.S.: suggestions for a better name than IFormComponent are much
> > appreciated.
> >
>

Re: Refactor IFormSubmittingComponent to enhance FormTester

Posted by Johan Compagner <jc...@gmail.com>.
I am afraid if you create a iformcomponent that then those 2 methods
are not enough an people start to expect that the can just randomly
create a component implement the interface and they are done..

So for such an interface to exist then it also really have to be used
every where and not just in our testing part.

What i would do is just check in the tester with instanceof and cast
to what it finds

On 12/20/07, Gerolf Seitz <ge...@gmail.com> wrote:
> Hi folks,
>
> FormTester#submit(String) takes a buttonComponentId for submitting the Form
> with an alternate button.
> in #setValue, the corresponding Component is cast to a FormComponent. this
> makes it impossible to pass the id of
> a SubmitLink to #submit(String).
> #setValue only calls getInputName on the formComponent. the same method
> happens to be declared in
> IFormSubmittingComponent (IFSC) (which is implemented by AbstractSubmitLink)
>
> the idea is the following:
> + create a new interface IFormComponent
> + move the methods IFSC#getInputName and IFSC#getForm to IFormComponent
> + let IFSC extend IFormComponent
> + let FormComponent implement IFormComponent
> + let FormTester#setValue cast to IFormComponent instead of FormComponent
>
> this way, there's no API break, but FormTester can use
> IFormSubmittingComponents too.
>
> wdyt?
>
>   Gerolf
>
>
> P.S.: suggestions for a better name than IFormComponent are much
> appreciated.
>