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/07/29 10:18:47 UTC

show modal window without clicking on ajaxLink

Hi all,

I have a page with an AjaxLink which shows a modal window. This modal window
contains a form and when we submit the form, modal window disappear, my page
is reloaded and a second ajaxLink is created. When we click on this second
ajaxLink, another modal window appears.
This part works well, but now, I want that the second modal window appears
after submitting the first form (and so without clicking on the second ajax
Link).

I try this on my form onSubmit method :
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
    //[...] some form processing

    membreCourant = serviceMembre.enregistrerReponses(membreCourant,
questionnaireCourant);
    SessionE4N.get().setMembre(membreCourant);
    //reload the page, so first modal window disappears and second ajax link
is created
    setResponsePage(QuestionnairesPage.class, new PageParameters("p=3"));

    //on affiche le module correspondant au questionnaire qu'on vient de
remplir
    qPage.getModuleContentPanel().initialiserModule(questionnaireCourant);
    qPage.getModalModule().setTitle("Module
"+questionnaireCourant.getTitre());
    qPage.getModalModule().show(target);
}

qPage is initialize on modal window constructor:
    public QuestionnaireContentPanel(String id, QuestionnairesPage
questionnairesPage){
        super(id);
        this.qPage = questionnairesPage;
        Form<Void> qForm = creationFormulaireQuestionnaire();
        add(qForm);
    }

but it doesn't work : second modal window is not shown.
What am I doing wrong?


This code in my page creates modal windows :
            modalQuestionnaire = new ModalWindowE4N("modalQuestionnaire",
"");
            questionnaireContentPanel = new
QuestionnaireContentPanel(modalQuestionnaire.getContentId(), this);
            modalQuestionnaire.setContent(questionnaireContentPanel);
            modalQuestionnaire.setInitialWidth(800);
            add(modalQuestionnaire);

            modalModule =  new ModalWindowE4N("modalModule", "");
            moduleContentPanel = new
ModuleContentPanel(modalModule.getContentId());
            modalModule.setContent(moduleContentPanel);
            modalModule.setInitialWidth(800);
            add(modalModule);

this code create ajaxLink for second modal windows (code for first modal
window is similar):
            //Repeatingview pour la liste des modules
            RepeatingView listeModules = new RepeatingView("listeModule");
            add(listeModules);

            List<ListeQuestionnaire> questionnaires =
membre.getListeQuestionnaires();
            for (ListeQuestionnaire questionnaire : questionnaires) {
                    WebMarkupContainer item = new
WebMarkupContainer(listeModules.newChildId());
                    listeModules.add(item);

                    Questionnaire q = questionnaire.getQuestionnaire();
                    item.add(new Label("titreModule", "Module
"+q.getTitre()));
                    item.add(new BoutonVisualiserModule("boutonModule",  new
Model<Questionnaire>(q)));
            }

and BoutonVisualiserModule :
    class BoutonVisualiserModule extends Panel
    {
        public BoutonVisualiserModule(String id, IModel<?> model) {
            super(id, model);

            //Ajout du lien qui affichera le module
            AjaxLink<Void> showModule = new AjaxLink<Void>("visualiser") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    qCourant =
(Questionnaire)getParent().getDefaultModelObject();


target.appendJavascript("Wicket.Window.unloadConfirmation = false;");
                    moduleContentPanel.initialiserModule(qCourant);
                    modalModule.setTitle("Module "+qCourant.getTitre());
                    modalModule.show(target);
                }
            };
            add(showModule);
        }
    }


-- 
*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 Sven Meier <sv...@meiers.net>.
Hi,

>setResponsePage(QuestionnairesPage.class, new PageParameters("p=3"));

you're leaving the current page before it can open the new modal window.

Try this instread:

firstPage.getModalModule().close(target); 

...

qPage.getModalModule().show(target); 

Hope this helps
Sven

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/show-modal-window-without-clicking-on-ajaxLink-tp3703364p3703409.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: show modal window without clicking on ajaxLink

Posted by Andrea Del Bene <ad...@ciseonweb.it>.
Hi Mathilde,

why not simply substitute modal window content instead of reloading page 
and creating a brand new modal window?
Your code doesn't work because setResponsePage create a new instance of 
QuestionnairesPage different from the one referenced by qPage variable.


> Hi all,
>
> I have a page with an AjaxLink which shows a modal window. This modal window
> contains a form and when we submit the form, modal window disappear, my page
> is reloaded and a second ajaxLink is created. When we click on this second
> ajaxLink, another modal window appears.
> This part works well, but now, I want that the second modal window appears
> after submitting the first form (and so without clicking on the second ajax
> Link).
>
> I try this on my form onSubmit method :
> protected void onSubmit(AjaxRequestTarget target, Form<?>  form) {
>      //[...] some form processing
>
>      membreCourant = serviceMembre.enregistrerReponses(membreCourant,
> questionnaireCourant);
>      SessionE4N.get().setMembre(membreCourant);
>      //reload the page, so first modal window disappears and second ajax link
> is created
>      setResponsePage(QuestionnairesPage.class, new PageParameters("p=3"));
>
>      //on affiche le module correspondant au questionnaire qu'on vient de
> remplir
>      qPage.getModuleContentPanel().initialiserModule(questionnaireCourant);
>      qPage.getModalModule().setTitle("Module
> "+questionnaireCourant.getTitre());
>      qPage.getModalModule().show(target);
> }
>
> qPage is initialize on modal window constructor:
>      public QuestionnaireContentPanel(String id, QuestionnairesPage
> questionnairesPage){
>          super(id);
>          this.qPage = questionnairesPage;
>          Form<Void>  qForm = creationFormulaireQuestionnaire();
>          add(qForm);
>      }
>
> but it doesn't work : second modal window is not shown.
> What am I doing wrong?


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


Re: show modal window without clicking on ajaxLink

Posted by Andrea Del Bene <ad...@ciseonweb.it>.
Try to use just one modal window and switch content panels. I.e:

-Create modal window with questionnaireContentPanel as initial content:

modalQuestionnaireModule = new 
ModalWindowE4N("modalQuestionnaireModule","");
questionnaireContentPanel = new 
QuestionnaireContentPanel(modalQuestionnaireModule.getContentId(), this);

modalQuestionnaireModule.setContent(questionnaireContentPanel);
modalQuestionnaireModule.setInitialWidth(800);

add(modalQuestionnaireModule);


-Show modal window
....


-After submit substitute window content with ModuleContentPanel:


protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
     //[...] some form processing

     membreCourant = serviceMembre.enregistrerReponses(membreCourant,
questionnaireCourant);
     SessionE4N.get().setMembre(membreCourant);

     //substitute window content
     Panel newContent = new 
ModuleContentPanel(modalQuestionnaireModule.getContentId(), this);
     modalQuestionnaireModule.setContent(newContent);

     //re-render window itself.
     target.addComponent(modalQuestionnaireModule);



> Well, I talked too fast.
> In fact, with Sven's solution :
>
>                  membreCourant =
> serviceMembre.enregistrerReponses(membreCourant, questionnaireCourant);
>                  SessionE4N.get().setMembre(membreCourant);
>                  //setResponsePage(QuestionnairesPage.class, new
> PageParameters("p=3"));
>
>                  qPage.getModalQuestionnaire().close(target);
>
>                  //on affiche le module correspondant au questionnaire qu'on
> vient de remplir
>
> qPage.getModuleContentPanel().initialiserModule(questionnaireCourant);
>                  qPage.getModalModule().setTitle("Module
> "+questionnaireCourant.getTitre());
>                  qPage.getModalModule().show(target);
>
> first modal window is closed, but the second is not really shown : in fact,
> a modal window empty appears, but it has the first modal window title. (and
> second modal window shouldn't be empty thanks to method initialiserModule)
> I don't understand what happen, so if you have an idea, let me know...
>
>
> 2011/7/29 Mathilde Pellerin<ma...@statlife.fr>
>
>> Thanks a lot for your answer.
>> The solution of Sven Meier works well.
>>
>> Sometimes I wonder why I always try complex solutions instead of simplest
>> one...
>>
>
>


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


Re: show modal window without clicking on ajaxLink

Posted by Andrea Del Bene <ad...@ciseonweb.it>.
Sorry, you are right. Under wicket 1.5 works calling replaceWith on old 
content. In your code should be something like :

moduleContentPanel = 
questionnaireContentPanel.replaceWith(moduleContentPanel);
target.addComponent(moduleContentPanel);


I didn't tested it with 1.4.x version.



> I tried your solution Andrea :
> - just one modal window :s
>              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?
>


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


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


Re: show modal window without clicking on ajaxLink

Posted by 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

Re: show modal window without clicking on ajaxLink

Posted by 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?

Re: show modal window without clicking on ajaxLink

Posted by Mathilde Pellerin <ma...@statlife.fr>.
Well, I talked too fast.
In fact, with Sven's solution :

                membreCourant =
serviceMembre.enregistrerReponses(membreCourant, questionnaireCourant);
                SessionE4N.get().setMembre(membreCourant);
                //setResponsePage(QuestionnairesPage.class, new
PageParameters("p=3"));

                qPage.getModalQuestionnaire().close(target);

                //on affiche le module correspondant au questionnaire qu'on
vient de remplir

qPage.getModuleContentPanel().initialiserModule(questionnaireCourant);
                qPage.getModalModule().setTitle("Module
"+questionnaireCourant.getTitre());
                qPage.getModalModule().show(target);

first modal window is closed, but the second is not really shown : in fact,
a modal window empty appears, but it has the first modal window title. (and
second modal window shouldn't be empty thanks to method initialiserModule)
I don't understand what happen, so if you have an idea, let me know...


2011/7/29 Mathilde Pellerin <ma...@statlife.fr>

> Thanks a lot for your answer.
> The solution of Sven Meier works well.
>
> Sometimes I wonder why I always try complex solutions instead of simplest
> one...
>



-- 
*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>.
Thanks a lot for your answer.
The solution of Sven Meier works well.

Sometimes I wonder why I always try complex solutions instead of simplest
one...