Hi,

I've adapted (and tested) my solution to wicket 1.4.17. It's slightly different from 1.5 because you should pass target.addComponent just moduleContentPanel and not the whole window. The code of my solution is this:

//modal window constructor
....
add(new AjaxLink("btn") {
            @Override
            public void onClick(AjaxRequestTarget target) {
                Component cmp;
getParent().replaceWith(cmp = new Label(modalWindow.getContentId(), "test"));
                cmp.setOutputMarkupId(true);

                target.addComponent(cmp);
            }
        });


It just replaces modal window content with a label.


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<mathilde.pelle...@statlife.fr>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to