You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Mathilde Pellerin <ma...@statlife.fr> on 2011/06/09 11:06:33 UTC

setEnabled(true) doesn't work on onUpdate method

Hi all,

In a form, I have a textfield and a button which is disable. I want to
enable the button when user enter a value on textfield.

so I do that :
        emailField.add(new AjaxFormComponentUpdatingBehavior("onkeyup") {

            @Override
            protected void onUpdate(AjaxRequestTarget target) {
                System.out.println("------------ onUpdate trace");
                submitButton.setEnabled(true);
            }
        });

onUpdate method is called (I have the trace in console) but my button is
still disable...

This is the code of the button :
        final Button submitButton = new Button("submitButton");
        submitButton.setEnabled(false);

I don't understand why this code doesn't work because I saw similar code on
the Web that seems to work.

Thanks for your help.

-- 
*Mathilde Pellerin*
Ingénieur en développement de logiciel

STATLIFE
tel : 01.42.11.64.88
mail : mathilde.pellerin@statlife.fr

Re: setEnabled(true) doesn't work on onUpdate method

Posted by Martin Grigorov <mg...@apache.org>.
On Thu, Jun 9, 2011 at 11:06 AM, Mathilde Pellerin
<ma...@statlife.fr> wrote:
> Hi all,
>
> In a form, I have a textfield and a button which is disable. I want to
> enable the button when user enter a value on textfield.
>
> so I do that :
>        emailField.add(new AjaxFormComponentUpdatingBehavior("onkeyup") {
>
>            @Override
>            protected void onUpdate(AjaxRequestTarget target) {
>                System.out.println("------------ onUpdate trace");
>                submitButton.setEnabled(true);
target.add(submitButton);
>            }
>        });
>
> onUpdate method is called (I have the trace in console) but my button is
> still disable...
>
> This is the code of the button :
>        final Button submitButton = new Button("submitButton");
>        submitButton.setEnabled(false);
>
> I don't understand why this code doesn't work because I saw similar code on
> the Web that seems to work.
>
> Thanks for your help.
>
> --
> *Mathilde Pellerin*
> Ingénieur en développement de logiciel
>
> STATLIFE
> tel : 01.42.11.64.88
> mail : mathilde.pellerin@statlife.fr
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setEnabled(true) doesn't work on onUpdate method

Posted by Mathilde Pellerin <ma...@gmail.com>.
of course, it works.
Thanks a lot !

2011/6/10 Martin Grigorov <mg...@apache.org>

> On Fri, Jun 10, 2011 at 9:42 AM, Mathilde Pellerin
> <ma...@statlife.fr> wrote:
> > Thanks for your answer, it works with
> > target.addComponent(submitButton);
> >
> > one more little question : how can I test my form with wicket tester?
> > Because formTester.setValue doesn't send "keyup" event... so my button is
> > still disable when I test my form with JUnit and WicketTester.
> > I try with :
> > tester.executeAjaxEvent("infosPersoForm:email", "keyup");
> tester.executeAjaxEvent("infosPersoForm:email", "onkeyup");
> >
> > but I get an error :
> > org.apache.wicket.WicketRuntimeException: No AjaxEventBehavior found on
> > component: email which matches the event: keyup
> >
> > Is it possible to simulate event with Wicket Tester?
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
 Mathilde Pellerin  Ingénieur en Génie Logiciel  Tél mobile :
06.60.78.79.03   E-mail
: mathilde.pellerin@gmail.com   Mon CV en ligne :
<http://www.mathilde-pellerin.fr/> http://www.mathilde-pellerin.fr/    Mes
liens :  <http://www.viadeo.com/fr/profile/mathilde.pellerin>
<http://fr.linkedin.com/in/mathildepellerin>

Re: setEnabled(true) doesn't work on onUpdate method

Posted by Martin Grigorov <mg...@apache.org>.
On Fri, Jun 10, 2011 at 9:42 AM, Mathilde Pellerin
<ma...@statlife.fr> wrote:
> Thanks for your answer, it works with
> target.addComponent(submitButton);
>
> one more little question : how can I test my form with wicket tester?
> Because formTester.setValue doesn't send "keyup" event... so my button is
> still disable when I test my form with JUnit and WicketTester.
> I try with :
> tester.executeAjaxEvent("infosPersoForm:email", "keyup");
tester.executeAjaxEvent("infosPersoForm:email", "onkeyup");
>
> but I get an error :
> org.apache.wicket.WicketRuntimeException: No AjaxEventBehavior found on
> component: email which matches the event: keyup
>
> Is it possible to simulate event with Wicket Tester?
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setEnabled(true) doesn't work on onUpdate method

Posted by Mathilde Pellerin <ma...@statlife.fr>.
Thanks for your answer, it works with
target.addComponent(submitButton);

one more little question : how can I test my form with wicket tester?
Because formTester.setValue doesn't send "keyup" event... so my button is
still disable when I test my form with JUnit and WicketTester.
I try with :
tester.executeAjaxEvent("infosPersoForm:email", "keyup");

but I get an error :
org.apache.wicket.WicketRuntimeException: No AjaxEventBehavior found on
component: email which matches the event: keyup

Is it possible to simulate event with Wicket Tester?