You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by lucast <lu...@hotmail.com> on 2014/06/25 14:00:53 UTC

WicketTester.executeAjaxEvent causes problems with FormTester.setValue()

Dear Forum,
I have come across a strange behaviour when running
wicketTester.executeAjaxEvent and FormTester on form fields with
setRequired( true );

If I call formTester.setValue(), followed by
wicketTester.executeAjaxEvent(), followed by formTester.submit(), the values
on the form fields are cleared. Form return errors.

If I call wicketTester.executeAjaxEvent() *first*, followed by 
formTester.setValue(),  followed by formTester.submit(), then the test
executes as expected.

Is there a rule somewhere that says that ajax behaviour should be executed
first, before setting form values? 

Is this behaviour correct or could it be that it is a bug with WicketTester
or formTester?

I've attached the code for quick behaviour reproduction.

Thanks in advance,
Lucas

TestHomePage.java
<http://apache-wicket.1842946.n4.nabble.com/file/n4666379/TestHomePage.java>  
HomePage.java
<http://apache-wicket.1842946.n4.nabble.com/file/n4666379/HomePage.java>  
HomePage.html
<http://apache-wicket.1842946.n4.nabble.com/file/n4666379/HomePage.html>  



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/WicketTester-executeAjaxEvent-causes-problems-with-FormTester-setValue-tp4666379.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: WicketTester.executeAjaxEvent causes problems with FormTester.setValue()

Posted by "mitchell.fr" <ha...@hotmail.fr>.
Hi Lucas,
I think it's a bug, because in my case I have a from when i set values of
some component, then i execute ajaw event to submit the form, wickettester
execute what i want, but after that if i submit the form with
formTester.submit('path'); i'm getting the same the result as if clicked on
the ajax button.

FormTester formTester = wicketTester.newFormTester("");
form.setvalue("","");
form.setvalue("",""); 
wicketTester.executeAjaxEvent("pathtoajaxbutton"); //until OK and i get what
i want
//now i have a normal submit button of the same form (formTester ) so i will
do :
formTester.submit("pathToOtherNONAjaxSubmitButton"); //KO failed,
wicketTester execute the last submit...

this is completely weird.... 

Hamed ops Mitchell 



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/WicketTester-executeAjaxEvent-causes-problems-with-FormTester-setValue-tp4666379p4666488.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: WicketTester.executeAjaxEvent causes problems with FormTester.setValue()

Posted by lucast <lu...@hotmail.com>.
Thanks for the reply.
I wasn't aware that values are consumed  after an ajax request.

My bad.

Thanks for taking the time to reply. It really does make a difference.

Regards,
Lucas

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/WicketTester-executeAjaxEvent-causes-problems-with-FormTester-setValue-tp4666379p4666382.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: WicketTester.executeAjaxEvent causes problems with FormTester.setValue()

Posted by Martin Grigorov <mg...@apache.org>.
I thought that someone moderates my responses but No, they are published:
http://markmail.org/message/e5qhl5nlo2nlwmeh
Since 6.16.0 you can do:
formTester.setValue() // value is set
formTester.setValue() // value is set
formTester.submit(pathToAjaxSubmitter) // values are submitted and consumed


Martin Grigorov
Wicket Training and Consulting


On Wed, Jun 25, 2014 at 3:06 PM, Sven Meier <sv...@meiers.net> wrote:

> Hi,
>
> everytime WicketTester processes a request, all previously set values are
> consumed, i.e. no longer present for the next request.
>
> formTester.setValue() // value is set
> wicketTester.executeAjaxEvent() // values are consumed
> formTester.submit() // no values
>
> wicketTester.executeAjaxEvent() // no values
> formTester.setValue() // value is set
> formTester.submit() // values are consumed
>
> You probably need:
>
> formTester.setValue() // value is set
> wicketTester.executeAjaxEvent() // values are consumed
> formTester.setValue() // value is set
> formTester.submit() // values are consumed
>
>
> Hope this helps
> Sven
>
>
>
> On 06/25/2014 02:00 PM, lucast wrote:
>
>> Dear Forum,
>> I have come across a strange behaviour when running
>> wicketTester.executeAjaxEvent and FormTester on form fields with
>> setRequired( true );
>>
>> If I call formTester.setValue(), followed by
>> wicketTester.executeAjaxEvent(), followed by formTester.submit(), the
>> values
>> on the form fields are cleared. Form return errors.
>>
>> If I call wicketTester.executeAjaxEvent() *first*, followed by
>> formTester.setValue(),  followed by formTester.submit(), then the test
>> executes as expected.
>>
>> Is there a rule somewhere that says that ajax behaviour should be executed
>> first, before setting form values?
>>
>> Is this behaviour correct or could it be that it is a bug with
>> WicketTester
>> or formTester?
>>
>> I've attached the code for quick behaviour reproduction.
>>
>> Thanks in advance,
>> Lucas
>>
>> TestHomePage.java
>> <http://apache-wicket.1842946.n4.nabble.com/file/n4666379/
>> TestHomePage.java>
>> HomePage.java
>> <http://apache-wicket.1842946.n4.nabble.com/file/n4666379/HomePage.java>
>> HomePage.html
>> <http://apache-wicket.1842946.n4.nabble.com/file/n4666379/HomePage.html>
>>
>>
>>
>> --
>> View this message in context: http://apache-wicket.1842946.
>> n4.nabble.com/WicketTester-executeAjaxEvent-causes-
>> problems-with-FormTester-setValue-tp4666379.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: WicketTester.executeAjaxEvent causes problems with FormTester.setValue()

Posted by Sven Meier <sv...@meiers.net>.
Hi,

everytime WicketTester processes a request, all previously set values 
are consumed, i.e. no longer present for the next request.

formTester.setValue() // value is set
wicketTester.executeAjaxEvent() // values are consumed
formTester.submit() // no values

wicketTester.executeAjaxEvent() // no values
formTester.setValue() // value is set
formTester.submit() // values are consumed

You probably need:

formTester.setValue() // value is set
wicketTester.executeAjaxEvent() // values are consumed
formTester.setValue() // value is set
formTester.submit() // values are consumed


Hope this helps
Sven


On 06/25/2014 02:00 PM, lucast wrote:
> Dear Forum,
> I have come across a strange behaviour when running
> wicketTester.executeAjaxEvent and FormTester on form fields with
> setRequired( true );
>
> If I call formTester.setValue(), followed by
> wicketTester.executeAjaxEvent(), followed by formTester.submit(), the values
> on the form fields are cleared. Form return errors.
>
> If I call wicketTester.executeAjaxEvent() *first*, followed by
> formTester.setValue(),  followed by formTester.submit(), then the test
> executes as expected.
>
> Is there a rule somewhere that says that ajax behaviour should be executed
> first, before setting form values?
>
> Is this behaviour correct or could it be that it is a bug with WicketTester
> or formTester?
>
> I've attached the code for quick behaviour reproduction.
>
> Thanks in advance,
> Lucas
>
> TestHomePage.java
> <http://apache-wicket.1842946.n4.nabble.com/file/n4666379/TestHomePage.java>
> HomePage.java
> <http://apache-wicket.1842946.n4.nabble.com/file/n4666379/HomePage.java>
> HomePage.html
> <http://apache-wicket.1842946.n4.nabble.com/file/n4666379/HomePage.html>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/WicketTester-executeAjaxEvent-causes-problems-with-FormTester-setValue-tp4666379.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


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