Re: FormTester and Ajax
Hi, FormTest#select() sets the value of that component into the request *and* submits it - the request is then *cleared* for the upcoming request. Thus when you call #executeBehavior() afterwards, the request will be completely empty and no company is select. You will have to set the value of that component once again. Have fun Sven Am 08.04.2018 um 14:41 schrieb Virginie Garcin: Hello, Sorry for the ugly formatting, I hope this will be displayed correctly below: Hello, I need some help with FormTester and Ajax. I want to test a form, in which the second dropdown is updated in ajax when we change the first dropdown. The form is working fine but I can't manage to test it. DropDownChoice companyDropDownChoice = new DropDownChoice<>( "company", LoadableDetachableModel.of( ()-> getCompaniesList() ), new CompanyChoiceRenderer<>() ); managerDropDownChoice.setRequired( true ); form.add( companyDropDownChoice ); DropDownChoice managerDropDownChoice = new DropDownChoice<>( "manager", LoadableDetachableModel.of( () -> getUserList(companyDropDownChoice.getConvertedInput()) ), new UserChoiceRenderer<>() ); managerDropDownChoice.setRequired( true ); form.add( managerDropDownChoice ); companyDropDownChoice.add( new AjaxFormComponentUpdatingBehavior( "change" ) { @Override protected void onUpdate(AjaxRequestTarget target) { target.add( managerDropDownChoice ); } } ); //test FormTester formTester = tester.newFormTester( "form" ); formTester.select( "company", 0 ); tester.executeBehavior( (AbstractAjaxBehavior) tester.getComponentFromLastRenderedPage( "form:company" ).getBehaviors().get( 0 ) ); formTester.select( "manager", 0 ); // Throws java.lang.IndexOutOfBoundsException: Index 0 out-of-bounds for length 0 Of course I made sure that when the company at index 0, getUserList() returns some items. Also, I made sure that when calling tester.executeBehavior, getCompaniesList() is indeed called. It's more like if formTester does not update the dropdown... What am I missing? Thanks in advance, Virginie - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: How to remove jsessionid from the URL?
On the very first request, the server doesn't know whether or not cookies are supported, so encodes the session id in the URL in addition to setting the cookie. There is a trick that involves forcing the browser to redirect the first request so that the server can determine that cookies are supported and omit the session id in the URL. On Sat, Apr 7, 2018, 9:40 PM gcsaba2 wrote: > Hello, > > I'm using Wicket 7 with Spring Boot. I've mounted several pages, and for > example when I go to search.html, the ;jsessionid always gets attached to > the URL. > > Is there some way to remove the jsessionid from the URLs? > > In the tomcat configuration I've already set the tracking-mode to be > cookie, > but still wicket puts the jsessionid in the url. What's even worse is that > all the links in the page have the jsessionid appended to the URL, so even > if I click anywhere, it will remain there. I would maybe accept it being > there the first time I visit the website and the session gets established, > but afterwards it's really unnecessary (and ugly). > > Thanks, > Csaba > > > -- > Sent from: > http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Re: FormTester and Ajax
Hello, Sorry for the ugly formatting, I hope this will be displayed correctly below: Hello, I need some help with FormTester and Ajax. I want to test a form, in which the second dropdown is updated in ajax when we change the first dropdown. The form is working fine but I can't manage to test it. DropDownChoice companyDropDownChoice = new DropDownChoice<>( "company", LoadableDetachableModel.of( ()-> getCompaniesList() ), new CompanyChoiceRenderer<>() ); managerDropDownChoice.setRequired( true ); form.add( companyDropDownChoice ); DropDownChoice managerDropDownChoice = new DropDownChoice<>( "manager", LoadableDetachableModel.of( () -> getUserList(companyDropDownChoice.getConvertedInput()) ), new UserChoiceRenderer<>() ); managerDropDownChoice.setRequired( true ); form.add( managerDropDownChoice ); companyDropDownChoice.add( new AjaxFormComponentUpdatingBehavior( "change" ) { @Override protected void onUpdate(AjaxRequestTarget target) { target.add( managerDropDownChoice ); } } ); //test FormTester formTester = tester.newFormTester( "form" ); formTester.select( "company", 0 ); tester.executeBehavior( (AbstractAjaxBehavior) tester.getComponentFromLastRenderedPage( "form:company" ).getBehaviors().get( 0 ) ); formTester.select( "manager", 0 ); // Throws java.lang.IndexOutOfBoundsException: Index 0 out-of-bounds for length 0 Of course I made sure that when the company at index 0, getUserList() returns some items. Also, I made sure that when calling tester.executeBehavior, getCompaniesList() is indeed called. It's more like if formTester does not update the dropdown... What am I missing? Thanks in advance, Virginie - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
FormTester and Ajax
Hello, I need some help with FormTester and Ajax.I want to test a form, in which the second dropdown is updated in ajax when we change the first dropdown.The form is working fine but I can't manage to test it. DropDownChoice companyDropDownChoice = new DropDownChoice<>( "company", LoadableDetachableModel.of( ()-> getCompaniesList() ), new CompanyChoiceRenderer<>() );managerDropDownChoice.setRequired( true );form.add( companyDropDownChoice ); DropDownChoice managerDropDownChoice = new DropDownChoice<>( "manager", LoadableDetachableModel.of( () -> getUserList(companyDropDownChoice.getConvertedInput()) ), new UserChoiceRenderer<>() );managerDropDownChoice.setRequired( true );form.add( managerDropDownChoice ); companyDropDownChoice.add( new AjaxFormComponentUpdatingBehavior( "change" ) { @Override protected void onUpdate(AjaxRequestTarget target) { target.add( managerDropDownChoice );}} ); //testFormTester formTester = tester.newFormTester( "form" );formTester.select( "company", 0 );tester.executeBehavior( (AbstractAjaxBehavior) tester.getComponentFromLastRenderedPage( "form:company" ).getBehaviors().get( 0 ) );formTester.select( "manager", 0 ); // Throws java.lang.IndexOutOfBoundsException: Index 0 out-of-bounds for length 0 Of course I made sure that for the company at index 0, getUserList() returns some items.Also, I made sure that when calling tester.executeBehavior, getCompaniesList() is indeed called. It's more like if formTester does not update the dropdown... What am I missing? Thanks in advance,Virginie