Thank you very much Andrea. Now unit tests are OK and it works well when I test it manually.
2011/8/1 Mathilde Pellerin <[email protected]> > I use Wicket 1.4.17. > I tried with replaceWith like this : > //affichage du module interactif > String idContent = qPage.getModalWindow().getContentId(); > ModuleContentPanel moduleContentPanel = new > ModuleContentPanel(idContent); > moduleContentPanel.initialiserModule(questionnaireCourant); > > qPage.getModalWindow().get(idContent).replaceWith(moduleContentPanel); > > qPage.getModalWindow().setTitle("Module > "+questionnaireCourant.getTitre()); > //qPage.getModalWindow().setContent(moduleContentPanel); > > target.addComponent(qPage.getModalWindow()); > > and it's weird : my unit test is OK > @Test > public void testStory09_TA01(){ > tester.startPage(QuestionnairesPage.class); > //On répond au questionnaire > Component module = reponseQuestionnaireNutrition(); > //et on vérifie que le module s'affiche bien > tester.assertNoErrorMessage(); > tester.assertRenderedPage(QuestionnairesPage.class); > tester.assertVisible(module.getPageRelativePath()); > } > > but when I test manually I can see that content panel of modal window is > still the same... > > > > Maybe reponseQuestionnaireNutrition() can be useful to understand my test: > private Component reponseQuestionnaireNutrition() { > //Récupération des composants présents dans la fenetre du > questionnaire > ModalWindowE4N modalWindowQuestionnaire = (ModalWindowE4N) > tester.getComponentFromLastRenderedPage("fenetreModale"); > QuestionnaireContentPanel questionnairePanel = > (QuestionnaireContentPanel) > modalWindowQuestionnaire.get(modalWindowQuestionnaire.getContentId()); > Form<?> qForm = (Form<?>) questionnairePanel.get("qForm"); > > tester.assertInvisible(qForm.getPageRelativePath()); > > tester.clickLink("listeQuestionnaire:1:boutonQuestionnaire:remplir"); > tester.assertVisible(qForm.getPageRelativePath()); > > //creation d'un formTester > FormTester formTester = > tester.newFormTester(qForm.getPageRelativePath()); > > //on répond aux questions > RepeatingView view = (RepeatingView) qForm.get("qRepeating"); > Iterator<? extends Component> iter = view.iterator(); > int index = 2; > while(iter.hasNext()){ > //on selectionne une reponse > formTester.select("qRepeating:"+index+":reponse:reponseListe", > 2); > iter.next(); > index++; > } > //puis on soumet le formulaire > tester.executeAjaxEvent(qForm.get("ajaxSubmitQuestionnaire"), > "onclick"); > ModuleContentPanel modulePanel = (ModuleContentPanel) > modalWindowQuestionnaire.get(modalWindowQuestionnaire.getContentId()); > Component module = modulePanel.get("module"); > module = modulePanel.get("module"); > return module; > } > > 2011/7/29 Mathilde Pellerin <[email protected]> > >> I tried your solution Andrea : >> - just one modal window : >> modalWindow = new ModalWindowE4N("modalQuestionnaire", ""); >> questionnaireContentPanel = new >> QuestionnaireContentPanel(modalWindow.getContentId(), this); >> modalWindow.setContent(questionnaireContentPanel); >> modalWindow.setInitialWidth(800); >> add(modalWindow); >> >> - after submit, substitute window content with ModuleContentPanel : >> >> membreCourant = >> serviceMembre.enregistrerReponses(membreCourant, questionnaireCourant); >> SessionE4N.get().setMembre(membreCourant); >> //qPage.getModalWindow().close(target); >> ModuleContentPanel moduleContentPanel = new >> ModuleContentPanel(qPage.getModalWindow().getContentId()); >> >> moduleContentPanel.initialiserModule(questionnaireCourant); >> qPage.getModalWindow().setTitle("Module >> "+questionnaireCourant.getTitre()); >> qPage.getModalWindow().setContent(moduleContentPanel); >> >> target.addComponent(qPage.getModalWindow()); >> //qPage.getModalWindow().show(target); >> >> but modal window is not re-render, so it content is not changed... >> maybe target.addComponent() is not sufficient? >> >> so I tried also with qPage.getModalWindow().close before changes and >> qPage.getModalWindow().show() after changes (with or without >> target.addComponent) : in these cases, we can see modal window change a >> second and then render with first content... >> >> what am I doing wrong? >> > > > > -- > *Mathilde Pellerin* > Ingénieur en développement de logiciel > > STATLIFE > tel : 01.42.11.64.88 > mail : [email protected] > > > > -- *Mathilde Pellerin* Ingénieur en développement de logiciel STATLIFE tel : 01.42.11.64.88 mail : [email protected]
