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