Re: Tester loses all submit parameters after ajax call
Hi Zilvinas, thank u for the test! We actually have different issues. I described mine at https://issues.apache.org/jira/browse/WICKET-3272 The tester setup the next request cycle just after process the request triggered by the mocked AJAX event. It differs from 1.4 where the request setup was made just before the next processRequestCycle. So in the 1.5 you don't need methods like setParametersForNextRequest, because the current request set on tester is the one that will be dispatched. So if you want to access it after process the request, you need to use methods like getLastRequest. I'm sending your test case back with mentioned changes. On Sat, Dec 18, 2010 at 4:14 PM, zkybar...@gmail.com zkybar...@gmail.comwrote: Pedro, One more thing, i have updated WicketTesterTest, which fails with issue i have described. I'm attaching patch file, maybe it will be of any help for you. On Sat, Dec 18, 2010 at 8:07 PM, zkybar...@gmail.com zkybar...@gmail.comwrote: Pedro, Thanks for reply. Yeah i have workaround for this - i just reset submit parameters from last request to current request. On Sat, Dec 18, 2010 at 6:30 PM, Pedro Santos pedros...@gmail.comwrote: Hi Zilvinas, I'm taking a look at your described issue, for now try to set the parameter as a POST one. On Sat, Dec 18, 2010 at 2:15 PM, zkybar...@gmail.com zkybar...@gmail.comwrote: Hello, I'm experiencing strange behavior with WicketTester in 1.5 when using FormTester with ajax events. It works as follows: 1. Set some value via the FormTester to input field. 2. Invoke ajax event. In my case behaviour is AjaxFormComponentUpdatingBehavior. 3. After the ajax event was executed input fields getInput method returns null. And it should, since there are no submit parameters available anymore. Is that bug? It was working in 1.4, so my guess that its bug. Greetings, Zilvinas. -- Pedro Henrique Oliveira dos Santos -- Pedro Henrique Oliveira dos Santos
Re: Tester loses all submit parameters after ajax call
Hi Pedro, Yeah those are different issues. I understand that in 1.5 its different how tester works. I know how can i access those parameters through request. The issue i have, is that if you do ajax call in the middle between setting value to input and submiting from, FormTester loses that value (unless of course you reset parameters from previous request to current). So, my question is, what should I do with the issue I have, do you want me to create jira task? Is it bug at all? On Tue, Dec 21, 2010 at 4:31 PM, Pedro Santos pedros...@gmail.com wrote: Hi Zilvinas, thank u for the test! We actually have different issues. I described mine at https://issues.apache.org/jira/browse/WICKET-3272 The tester setup the next request cycle just after process the request triggered by the mocked AJAX event. It differs from 1.4 where the request setup was made just before the next processRequestCycle. So in the 1.5 you don't need methods like setParametersForNextRequest, because the current request set on tester is the one that will be dispatched. So if you want to access it after process the request, you need to use methods like getLastRequest. I'm sending your test case back with mentioned changes. On Sat, Dec 18, 2010 at 4:14 PM, zkybar...@gmail.com zkybar...@gmail.comwrote: Pedro, One more thing, i have updated WicketTesterTest, which fails with issue i have described. I'm attaching patch file, maybe it will be of any help for you. On Sat, Dec 18, 2010 at 8:07 PM, zkybar...@gmail.com zkybar...@gmail.com wrote: Pedro, Thanks for reply. Yeah i have workaround for this - i just reset submit parameters from last request to current request. On Sat, Dec 18, 2010 at 6:30 PM, Pedro Santos pedros...@gmail.comwrote: Hi Zilvinas, I'm taking a look at your described issue, for now try to set the parameter as a POST one. On Sat, Dec 18, 2010 at 2:15 PM, zkybar...@gmail.com zkybar...@gmail.comwrote: Hello, I'm experiencing strange behavior with WicketTester in 1.5 when using FormTester with ajax events. It works as follows: 1. Set some value via the FormTester to input field. 2. Invoke ajax event. In my case behaviour is AjaxFormComponentUpdatingBehavior. 3. After the ajax event was executed input fields getInput method returns null. And it should, since there are no submit parameters available anymore. Is that bug? It was working in 1.4, so my guess that its bug. Greetings, Zilvinas. -- Pedro Henrique Oliveira dos Santos -- Pedro Henrique Oliveira dos Santos
Re: Tester loses all submit parameters after ajax call
IMO it is not a bug, rather an improvement: set the form components value as parameter in form submit request. the scenario is: - a new form is created - a form components receive a new value in the first submit - in the second submit the new value at the form component didn't get add as an request parameter, like if the user manually removed the text in an text field for instance, or like if the form component get invisible. I don't know if FormTester was designed to simulate a second submit. On Tue, Dec 21, 2010 at 1:15 PM, zkybar...@gmail.com zkybar...@gmail.comwrote: Hi Pedro, Yeah those are different issues. I understand that in 1.5 its different how tester works. I know how can i access those parameters through request. The issue i have, is that if you do ajax call in the middle between setting value to input and submiting from, FormTester loses that value (unless of course you reset parameters from previous request to current). So, my question is, what should I do with the issue I have, do you want me to create jira task? Is it bug at all? On Tue, Dec 21, 2010 at 4:31 PM, Pedro Santos pedros...@gmail.com wrote: Hi Zilvinas, thank u for the test! We actually have different issues. I described mine at https://issues.apache.org/jira/browse/WICKET-3272 The tester setup the next request cycle just after process the request triggered by the mocked AJAX event. It differs from 1.4 where the request setup was made just before the next processRequestCycle. So in the 1.5 you don't need methods like setParametersForNextRequest, because the current request set on tester is the one that will be dispatched. So if you want to access it after process the request, you need to use methods like getLastRequest. I'm sending your test case back with mentioned changes. On Sat, Dec 18, 2010 at 4:14 PM, zkybar...@gmail.com zkybar...@gmail.comwrote: Pedro, One more thing, i have updated WicketTesterTest, which fails with issue i have described. I'm attaching patch file, maybe it will be of any help for you. On Sat, Dec 18, 2010 at 8:07 PM, zkybar...@gmail.com zkybar...@gmail.com wrote: Pedro, Thanks for reply. Yeah i have workaround for this - i just reset submit parameters from last request to current request. On Sat, Dec 18, 2010 at 6:30 PM, Pedro Santos pedros...@gmail.com wrote: Hi Zilvinas, I'm taking a look at your described issue, for now try to set the parameter as a POST one. On Sat, Dec 18, 2010 at 2:15 PM, zkybar...@gmail.com zkybar...@gmail.comwrote: Hello, I'm experiencing strange behavior with WicketTester in 1.5 when using FormTester with ajax events. It works as follows: 1. Set some value via the FormTester to input field. 2. Invoke ajax event. In my case behaviour is AjaxFormComponentUpdatingBehavior. 3. After the ajax event was executed input fields getInput method returns null. And it should, since there are no submit parameters available anymore. Is that bug? It was working in 1.4, so my guess that its bug. Greetings, Zilvinas. -- Pedro Henrique Oliveira dos Santos -- Pedro Henrique Oliveira dos Santos -- Pedro Henrique Oliveira dos Santos
Re: Tester loses all submit parameters after ajax call
In the 1.4 the executeAjaxEvent method do not create an request to be processed as in the 1.5. I prefer how it works in the 1.5, because when we don't use an AJAX request to trigger the default request cycle we need some hack in the tester, like: checkUsability. Perhaps we can even remove this method in the 1.5. On Tue, Dec 21, 2010 at 1:40 PM, Pedro Santos pedros...@gmail.com wrote: IMO it is not a bug, rather an improvement: set the form components value as parameter in form submit request. the scenario is: - a new form is created - a form components receive a new value in the first submit - in the second submit the new value at the form component didn't get add as an request parameter, like if the user manually removed the text in an text field for instance, or like if the form component get invisible. I don't know if FormTester was designed to simulate a second submit. On Tue, Dec 21, 2010 at 1:15 PM, zkybar...@gmail.com zkybar...@gmail.comwrote: Hi Pedro, Yeah those are different issues. I understand that in 1.5 its different how tester works. I know how can i access those parameters through request. The issue i have, is that if you do ajax call in the middle between setting value to input and submiting from, FormTester loses that value (unless of course you reset parameters from previous request to current). So, my question is, what should I do with the issue I have, do you want me to create jira task? Is it bug at all? On Tue, Dec 21, 2010 at 4:31 PM, Pedro Santos pedros...@gmail.com wrote: Hi Zilvinas, thank u for the test! We actually have different issues. I described mine at https://issues.apache.org/jira/browse/WICKET-3272 The tester setup the next request cycle just after process the request triggered by the mocked AJAX event. It differs from 1.4 where the request setup was made just before the next processRequestCycle. So in the 1.5 you don't need methods like setParametersForNextRequest, because the current request set on tester is the one that will be dispatched. So if you want to access it after process the request, you need to use methods like getLastRequest. I'm sending your test case back with mentioned changes. On Sat, Dec 18, 2010 at 4:14 PM, zkybar...@gmail.com zkybar...@gmail.comwrote: Pedro, One more thing, i have updated WicketTesterTest, which fails with issue i have described. I'm attaching patch file, maybe it will be of any help for you. On Sat, Dec 18, 2010 at 8:07 PM, zkybar...@gmail.com zkybar...@gmail.com wrote: Pedro, Thanks for reply. Yeah i have workaround for this - i just reset submit parameters from last request to current request. On Sat, Dec 18, 2010 at 6:30 PM, Pedro Santos pedros...@gmail.com wrote: Hi Zilvinas, I'm taking a look at your described issue, for now try to set the parameter as a POST one. On Sat, Dec 18, 2010 at 2:15 PM, zkybar...@gmail.com zkybar...@gmail.comwrote: Hello, I'm experiencing strange behavior with WicketTester in 1.5 when using FormTester with ajax events. It works as follows: 1. Set some value via the FormTester to input field. 2. Invoke ajax event. In my case behaviour is AjaxFormComponentUpdatingBehavior. 3. After the ajax event was executed input fields getInput method returns null. And it should, since there are no submit parameters available anymore. Is that bug? It was working in 1.4, so my guess that its bug. Greetings, Zilvinas. -- Pedro Henrique Oliveira dos Santos -- Pedro Henrique Oliveira dos Santos -- Pedro Henrique Oliveira dos Santos -- Pedro Henrique Oliveira dos Santos
Re: Tester loses all submit parameters after ajax call
On Tue, Dec 21, 2010 at 5:04 PM, Pedro Santos pedros...@gmail.com wrote: In the 1.4 the executeAjaxEvent method do not create an request to be processed as in the 1.5. I prefer how it works in the 1.5, because when we don't use an AJAX request to trigger the default request cycle we need some hack in the tester, like: checkUsability. Perhaps we can even remove this method in the 1.5. checkUsability() is there to stop requests to invisible/disabled components/behaviors I think WicketTester call trace doesn't reach to RequestListenerInterface where we recently added checks for that in the real environment On Tue, Dec 21, 2010 at 1:40 PM, Pedro Santos pedros...@gmail.com wrote: IMO it is not a bug, rather an improvement: set the form components value as parameter in form submit request. the scenario is: - a new form is created - a form components receive a new value in the first submit - in the second submit the new value at the form component didn't get add as an request parameter, like if the user manually removed the text in an text field for instance, or like if the form component get invisible. I don't know if FormTester was designed to simulate a second submit. On Tue, Dec 21, 2010 at 1:15 PM, zkybar...@gmail.com zkybar...@gmail.comwrote: Hi Pedro, Yeah those are different issues. I understand that in 1.5 its different how tester works. I know how can i access those parameters through request. The issue i have, is that if you do ajax call in the middle between setting value to input and submiting from, FormTester loses that value (unless of course you reset parameters from previous request to current). So, my question is, what should I do with the issue I have, do you want me to create jira task? Is it bug at all? On Tue, Dec 21, 2010 at 4:31 PM, Pedro Santos pedros...@gmail.com wrote: Hi Zilvinas, thank u for the test! We actually have different issues. I described mine at https://issues.apache.org/jira/browse/WICKET-3272 The tester setup the next request cycle just after process the request triggered by the mocked AJAX event. It differs from 1.4 where the request setup was made just before the next processRequestCycle. So in the 1.5 you don't need methods like setParametersForNextRequest, because the current request set on tester is the one that will be dispatched. So if you want to access it after process the request, you need to use methods like getLastRequest. I'm sending your test case back with mentioned changes. On Sat, Dec 18, 2010 at 4:14 PM, zkybar...@gmail.com zkybar...@gmail.comwrote: Pedro, One more thing, i have updated WicketTesterTest, which fails with issue i have described. I'm attaching patch file, maybe it will be of any help for you. On Sat, Dec 18, 2010 at 8:07 PM, zkybar...@gmail.com zkybar...@gmail.com wrote: Pedro, Thanks for reply. Yeah i have workaround for this - i just reset submit parameters from last request to current request. On Sat, Dec 18, 2010 at 6:30 PM, Pedro Santos pedros...@gmail.com wrote: Hi Zilvinas, I'm taking a look at your described issue, for now try to set the parameter as a POST one. On Sat, Dec 18, 2010 at 2:15 PM, zkybar...@gmail.com zkybar...@gmail.comwrote: Hello, I'm experiencing strange behavior with WicketTester in 1.5 when using FormTester with ajax events. It works as follows: 1. Set some value via the FormTester to input field. 2. Invoke ajax event. In my case behaviour is AjaxFormComponentUpdatingBehavior. 3. After the ajax event was executed input fields getInput method returns null. And it should, since there are no submit parameters available anymore. Is that bug? It was working in 1.4, so my guess that its bug. Greetings, Zilvinas. -- Pedro Henrique Oliveira dos Santos -- Pedro Henrique Oliveira dos Santos -- Pedro Henrique Oliveira dos Santos -- Pedro Henrique Oliveira dos Santos
Re: Tester loses all submit parameters after ajax call
Pedro, Thanks for reply. Yeah i have workaround for this - i just reset submit parameters from last request to current request. On Sat, Dec 18, 2010 at 6:30 PM, Pedro Santos pedros...@gmail.com wrote: Hi Zilvinas, I'm taking a look at your described issue, for now try to set the parameter as a POST one. On Sat, Dec 18, 2010 at 2:15 PM, zkybar...@gmail.com zkybar...@gmail.com wrote: Hello, I'm experiencing strange behavior with WicketTester in 1.5 when using FormTester with ajax events. It works as follows: 1. Set some value via the FormTester to input field. 2. Invoke ajax event. In my case behaviour is AjaxFormComponentUpdatingBehavior. 3. After the ajax event was executed input fields getInput method returns null. And it should, since there are no submit parameters available anymore. Is that bug? It was working in 1.4, so my guess that its bug. Greetings, Zilvinas. -- Pedro Henrique Oliveira dos Santos
Re: Tester loses all submit parameters after ajax call
Pedro, One more thing, i have updated WicketTesterTest, which fails with issue i have described. I'm attaching patch file, maybe it will be of any help for you. On Sat, Dec 18, 2010 at 8:07 PM, zkybar...@gmail.com zkybar...@gmail.comwrote: Pedro, Thanks for reply. Yeah i have workaround for this - i just reset submit parameters from last request to current request. On Sat, Dec 18, 2010 at 6:30 PM, Pedro Santos pedros...@gmail.com wrote: Hi Zilvinas, I'm taking a look at your described issue, for now try to set the parameter as a POST one. On Sat, Dec 18, 2010 at 2:15 PM, zkybar...@gmail.com zkybar...@gmail.com wrote: Hello, I'm experiencing strange behavior with WicketTester in 1.5 when using FormTester with ajax events. It works as follows: 1. Set some value via the FormTester to input field. 2. Invoke ajax event. In my case behaviour is AjaxFormComponentUpdatingBehavior. 3. After the ajax event was executed input fields getInput method returns null. And it should, since there are no submit parameters available anymore. Is that bug? It was working in 1.4, so my guess that its bug. Greetings, Zilvinas. -- Pedro Henrique Oliveira dos Santos Index: src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java === --- src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java (revision 1050371) +++ src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java (working copy) @@ -678,6 +678,15 @@ assertEquals(Mock name, pojo.getName()); } + public void testFormInputWithAjaxEvent() + { + tester.startPage(MockPageWithFormAndAjaxFormSubmitBehavior.class); + FormTester form = tester.newFormTester(form); + form.setValue(name, New name); + tester.executeAjaxEvent(form:name, onchange); + assertEquals(New name, ((FormComponent)form.getForm().get(name)).getInput()); + } + public void testSubmittingFormWithAjaxEventSubmitsFormValues() { tester.startPage(MockPageWithFormAndAjaxFormSubmitBehavior.class); Index: src/test/java/org/apache/wicket/util/tester/MockPageWithFormAndAjaxFormSubmitBehavior.java === --- src/test/java/org/apache/wicket/util/tester/MockPageWithFormAndAjaxFormSubmitBehavior.java (revision 1050371) +++ src/test/java/org/apache/wicket/util/tester/MockPageWithFormAndAjaxFormSubmitBehavior.java (working copy) @@ -19,6 +19,7 @@ import java.io.Serializable; import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; import org.apache.wicket.ajax.form.AjaxFormSubmitBehavior; import org.apache.wicket.markup.html.WebComponent; import org.apache.wicket.markup.html.WebPage; @@ -52,7 +53,15 @@ FormPojo form = new FormPojo(form, new CompoundPropertyModelPojo(pojo)); add(form); - form.add(new TextFieldString(name)); + TextFieldString field = new TextFieldString(name); + field.add(new AjaxFormComponentUpdatingBehavior(onchange) + { + @Override + protected void onUpdate(AjaxRequestTarget target) + { + } + }); + form.add(field); // The Event behavior WebComponent eventComponent = new WebComponent(EVENT_COMPONENT);