You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Mathilde Pellerin <ma...@statlife.fr> on 2011/08/01 09:28:59 UTC
Re: show modal window without clicking on ajaxLink
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 <ma...@statlife.fr>
> 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 : mathilde.pellerin@statlife.fr
Re: show modal window without clicking on ajaxLink
Posted by Mathilde Pellerin <ma...@statlife.fr>.
Thank you very much Andrea.
Now unit tests are OK and it works well when I test it manually.
2011/8/1 Mathilde Pellerin <ma...@statlife.fr>
> 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 <ma...@statlife.fr>
>
>> 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 : mathilde.pellerin@statlife.fr
>
>
>
>
--
*Mathilde Pellerin*
Ingénieur en développement de logiciel
STATLIFE
tel : 01.42.11.64.88
mail : mathilde.pellerin@statlife.fr
Re: show modal window without clicking on ajaxLink
Posted by Andrea Del Bene <ad...@ciseonweb.it>.
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<ma...@statlife.fr>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org