I tested a little bit but the reason is not so obviousthere is a series of 
DropDowbFields where each sets the choices for the next protected IModel<Land> 
selectedLand=new EntityModel<Land>(Land.class,null); protected IModel<Orte> 
selectedOrt=new EntityModel<Orte>(Orte.class,null);; protected IModel<Strassen> 
selectedStrasse=new EntityModel<Strassen>(Strassen.class,null); protected 
IModel<Objekte> selectedObjekt=new EntityModel<Objekte>(Objekte.class,null); 
IModel<List<? extends Land>>makeChoicesLand= new AbstractReadOnlyModel<List<? 
extends Land>>() { @Override public List<Land> getObject() { List<Land> 
landlist=new ArrayList<Land>(); if(landManager!=null){ Iterator 
landiterator=landManager.getLandes().iterator(); while(landiterator.hasNext()){ 
Land land=(Land) landiterator.next(); landlist.add(land); } } return landlist; 
} };  private IModel<List<? extends Orte>> makeChoicesOrt = new 
AbstractReadOnlyModel<List<? extends Orte>>() { @Override public List<Orte> 
getObject() { List<Orte> ortelist=new ArrayList<Orte>(); try{ if 
(selectedLand.getObject()!=null){  Iterator 
orteiterator=selectedLand.getObject().getOrte().iterator(); 
while(orteiterator.hasNext()){ Orte orte=(Orte)orteiterator.next();  Iterator 
strasseniterator=orte.getStrassen().iterator(); 
while(strasseniterator.hasNext()){ Strassen 
strassen=(Strassen)strasseniterator.next();  Iterator 
objekteiterator=strassen.getObjekte().iterator();  
while(objekteiterator.hasNext()){ Objekte 
objekte=(Objekte)objekteiterator.next(); } }  
if(Strings.isEmpty(selectedOrtstring)){ortelist.add(orte);}  else{ 
if(orte.getOrtname().startsWith(selectedOrtstring, 0)) ortelist.add(orte);  } } 
}  }catch(Exception e){System.err.println(e);} return ortelist; }  }; 


 private IModel<List<? extends Strassen>> makeChoicesStrassen = new 
AbstractReadOnlyModel<List<? extends Strassen>>() { @Override public 
List<Strassen> getObject() { List<Strassen> strassenlist=new 
ArrayList<Strassen>(); if (selectedOrt.getObject()!=null){   Iterator 
strasseniterator=selectedOrt.getObject().getStrassen().iterator(); 
while(strasseniterator.hasNext()){ Strassen 
strassen=(Strassen)strasseniterator.next(); 
if(Strings.isEmpty(selectedStrassenstring)){strassenlist.add(strassen);} else{ 
if(strassen.getStrname().startsWith(selectedStrassenstring, 0)) 
strassenlist.add(strassen); } }  }  return strassenlist; } }; 




 private IModel<List<? extends Objekte>> makeChoicesObjekte = new 
AbstractReadOnlyModel<List<? extends Objekte>>() { @Override public 
List<Objekte> getObject() { List<Objekte> objektelist=new ArrayList<Objekte>(); 
if(selectedStrasse.getObject()!=null){  Iterator 
objekteiterator=selectedStrasse.getObject().getObjekte().iterator();  
while(objekteiterator.hasNext()){ Objekte 
objekte=(Objekte)objekteiterator.next(); objektelist.add(objekte);  } }  return 
objektelist; } };  final DropDownChoice<Objekte> objekte = new 
DropDownChoice<Objekte>("objekte",new 
PropertyModel<Objekte>(this,"selectedObjekt.entity"), 
makeChoicesObjekte,objektechoicerenderer); final DropDownChoice<Land> land = 
new DropDownChoice<Land>("land",new 
PropertyModel<Land>(this,"selectedLand.entity"), makeChoicesLand,new 
ChoiceRenderer<Land>("landname","id")); final DropDownChoice<Orte> orte = new 
DropDownChoice<Orte>("orte",new PropertyModel<Orte>(this,"selectedOrt.entity"), 
makeChoicesOrt,new ChoiceRenderer<Orte>("ortname","id")); final 
DropDownChoice<Strassen> strassen = new DropDownChoice<Strassen>("strassen",new 
PropertyModel<Strassen>(this,"selectedStrasse.entity"), makeChoicesStrassen,new 
ChoiceRenderer<Strassen>("strname","id")); First only land is visible if 
selected orte becomes visible if this is selected the next dropdown becomes 
visible etc.
This is triggered by
land.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override 
protected void onUpdate(AjaxRequestTarget target) { 
ortemarkup.setVisible(true); target.add(ortemarkup); 
textsearchmarkup.setVisible(false); target.add(textsearchmarkup); }  }); 
 orte.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override 
protected void onUpdate(AjaxRequestTarget target) { 
strassenmarkup.setVisible(true); target.add(strassenmarkup); } }); 


strassen.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override 
protected void onUpdate(AjaxRequestTarget target) {  if(withNext==false){ 
customCSS = "btn btn-info pull-left col-sm-4 disabled"; customEnabled = false;} 
if(whithObjekt==1) {  objektemarkup.setVisible(true); 
personenmarkup.setVisible(false); } if(whithObjekt==2){ 
objektemarkup.setVisible(true); personenmarkup.setVisible(true); } 
if(whithObjekt==0){ objektemarkup.setVisible(false);  
personenmarkup.setVisible(false); } if(whithObjekt==-1) { 
personenmarkup.setVisible(true); objektemarkup.setVisible(false);} 
target.add(objektemarkup); target.add(personenmarkup); target.add(onNext); } 
});the dropdowns are in Markupcontainers which might be visible or not.In each 
position you can hit a nextButton.which looks which selectedFields are not 
empty and decides which action to take.
this works in real life and with WicketTester i make the following:
tester.executeUrl("../../wicket/bookmarkable/braunimmobilien.bootstrap.webapp.pages.breadcrumb.IndexBootstrap?objid=null");
 tester.assertRenderedPage(IndexBootstrap.class); FormTester formTester = 
tester.newFormTester("panel:form"); 
Assert.assertEquals("",formTester.getForm().getClass().getSimpleName(),"StrassenSucheForm");
 tester.assertInvisible("panel:form:ortemarkup:orte"); 
tester.assertInvisible("panel:form:eigentuemertypmarkup:eigentuemertyp"); 
tester.assertVisible("panel:form:landmarkup:land"); 
formTester.select("landmarkup:land", 0); 
tester.executeBehavior((AbstractAjaxBehavior)tester.getComponentFromLastRenderedPage("panel:form:landmarkup:land").getBehaviors().get(0));
 tester.assertVisible("panel:form:ortemarkup:orte"); 
tester.assertInvisible("panel:form:strassenmarkup:strassen"); 
formTester.select("ortemarkup:orte", 0); 
tester.executeBehavior((AbstractAjaxBehavior)tester.getComponentFromLastRenderedPage("panel:form:ortemarkup:orte").getBehaviors().get(0));
  tester.assertVisible("panel:form:strassenmarkup:strassen"); 
tester.assertInvisible("panel:form:objektemarkup:objekte"); 
formTester.select("strassenmarkup:strassen", 0); 
tester.executeBehavior((AbstractAjaxBehavior)tester.getComponentFromLastRenderedPage("panel:form:strassenmarkup:strassen").getBehaviors().get(0));
 tester.assertVisible("panel:form:objektemarkup:objekte"); 
formTester.submit("nextButton"); 
tester.assertRenderedPage(IndexBootstrap.class); formTester = 
tester.newFormTester("panel:form"); 
Assert.assertEquals("",formTester.getForm().getClass().getSimpleName(),"ObjektInput");
and found out that if i use 
tester.executeBehavior((AbstractAjaxBehavior)tester.getComponentFromLastRenderedPage("panel:form:strassenmarkup:strassen").getBehaviors().get(0));
 selectedStrasse is null so that the nextButton behaviour is not the same as in 
real life.
If i avoid the above i must also avoid  
tester.assertVisible("panel:form:objektemarkup:objekte");but the nextButton 
behaviour is then the same as in real life.This different behaviour is with all 
fields.When i select a dropdown and then immediately hit nextButton there is no 
difference in behaviout.so the difference in the behaviour of the IModel 
selectedFields comes by tester.executeBehavior where all set IModel fields are 
set at null

Reply via email to