It's definitively the combination wicket hibernate which provokes this behaviour.
Von meinem Samsung Galaxy Smartphone gesendet. -------- Ursprüngliche Nachricht --------Von: hansheinrichbraun <hansheinrichbr...@yahoo.de.INVALID> Datum: 11.06.16 15:41 (GMT+01:00) An: Martin Grigorov <mgrigo...@apache.org> Cc: Users <users@wicket.apache.org> Betreff: AW: Re: Re: Re: FormTester and IModel Martin thank you for your advice.i logged my Entity model and found that executeBehaviour set the properties to null.Then i blocked the null setting now the example was ok but now a property which had no Behaviour was set to null when i gave him a nonsense Behavior it worked.But i was not satisfied by the solution.I now made an IModel of a bean which included my properties for the form.still the nullifying problem.At the end i put all hibernate hsqld spring out of my example and it worked.So it must some of the packages i added which caused the problem.So i will go now the way back step by step.Any case thanks for you advice Von meinem Samsung Galaxy Smartphone gesendet. -------- Ursprüngliche Nachricht --------Von: Martin Grigorov <mgrigo...@apache.org> Datum: 30.05.16 16:52 (GMT+01:00) An: Hans-Heinrich Braun <hansheinrichbr...@yahoo.de> Cc: Users <users@wicket.apache.org> Betreff: Re: Re: Re: FormTester and IModel Hi, Please try to make the demo application simpler.At the moment is uses Spring, Hibernate, DBUtil, ... A simple Wicket-only application that demonstrates the problem should be possible to be created.Also try with default Wicket model classes. If it works then the problem should be in your EntityModel. Martin GrigorovWicket Training and Consulting https://twitter.com/mtgrigorov On Sun, May 29, 2016 at 6:54 PM, Hans-Heinrich Braun <hansheinrichbr...@yahoo.de> wrote: excuse me Martin that i confused you. So let me try to repeat once more the problem: there are 2 DropDownChoice Fields: 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")); setting the fields : IModel<Land> selectedLand=new EntityModel<Land>(Land.class,null); IModel<Orte> selectedOrt=new EntityModel<Orte>(Orte.class,null); the selection of land changes the choices of orte which i trigger by land.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { orte.setVisible(true); target.add(orte); } }); when i click nextButton i check which fields were set.. if land was set or if orte was set. this is ok when i run as webapplication under jetty. but when i test with WicketTester and FormTester : tester.assertInvisible("form:orte"); tester.assertVisible("form:land"); formTester.select("land", 0); tester.executeBehavior((AbstractAjaxBehavior)tester.getComponentFromLastRenderedPage("form:land").getBehaviors().get(0)); tester.assertVisible("form:orte"); formTester.submit("nextButton"); but formTester.submit("nextButton")finds land is null if land is set and orte not. Hope you are not fed up by my problemdescription Von: Martin Grigorov <mgrigo...@apache.org> An: hansheinrichbraun <hansheinrichbr...@yahoo.de> CC: "users@wicket.apache.org" <users@wicket.apache.org> Gesendet: 10:33 Mittwoch, 25.Mai 2016 Betreff: Re: Re: Re: FormTester and IModel On Wed, May 25, 2016 at 10:20 AM, hansheinrichbraun <hansheinrichbr...@yahoo.de> wrote: I thought i did the trigger here : tester.getComponentFromLastRenderedPage("form:land").getBehaviors().get(0)); This is just an execution of a getter.You need to tester.executeBehavior(ajaxBehavior) it Von meinem Samsung Galaxy Smartphone gesendet. -------- Ursprüngliche Nachricht --------Von: Martin Grigorov <mgrigo...@apache.org> Datum: 25.05.16 09:25 (GMT+01:00) An: hansheinrichbraun <hansheinrichbr...@yahoo.de> Cc: users@wicket.apache.org Betreff: Re: Re: FormTester and IModel Hi, On Wed, May 25, 2016 at 7:42 AM, hansheinrichbraun <hansheinrichbr...@yahoo.de> wrote: Excuse me i didn't communicate here for a long time so i am a little unfamiliar how to describe my problem here. so i try to describe it here and send you once more the reduced application there is a field i defined with my own EntityModel class IModel<Land> selectedLand=new EntityModel<Land>(Land.class,null); it is set by a DropDownChoice final DropDownChoice<Land> land > = new DropDownChoice<Land>("land",new > PropertyModel<Land>(this,"selectedLand.entity"), the selection of this field sets the Choices of another DropDownChoice by land.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override Here you use Ajax behavior to submit the form component. protected void onUpdate(AjaxRequestTarget target) {orte.setVisible(true); target.add(orte); } }); if i select land but don't select orte and then click at the nextButton when i run with jetty land is still set. when i simulate this behaviour by WicketTester and FormTester formTester.select("land", 0); Here you don't trigger trigger the Ajax behavior to update the model object of this form component, so its value is still the old. .getComponentFromLastRenderedPagtestere("form:land").getBehaviors().get(0));tester.assertVisible("form:orte"); formTester.submit("nextButton"); i found out in nextButton that land is null. Maybe it's my version of EntityModel i send you once more the whole application.Von meinem Samsung Galaxy Smartphone gesendet. -------- Ursprüngliche Nachricht --------Von: Martin Grigorov <mgrigo...@apache.org> Datum: 19.05.16 10:19 (GMT+01:00) An: users@wicket.apache.org, Hans-Heinrich Braun <hansheinrichbr...@yahoo.de> Betreff: Re: FormTester and IModel Sorry, but your email is hardly readable. You may use some pastebin service for the code. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, May 19, 2016 at 10:13 AM, Hans-Heinrich Braun < hansheinrichbr...@yahoo.de.invalid> wrote: > 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