problem to test form in modal window with wicket tester
Hi all, I have a modal window with a login form inside that works fine when I test it manually. I try to test it with wicket tester since yesterday. I saw in some mails of this list that there is nothing special in testing modal windows. I tried this : tester.startPage(AccueilPage.class); tester.clickLink(connexion); ModalWindowE4N modalWindow = (ModalWindowE4N) tester.getComponentFromLastRenderedPage(modalConnexion); tester.isVisible(modalWindow.getPageRelativePath() + : + modalWindow.getContentId()); Form? loginForm = (Form?) modalWindow.get(loginForm); Component feedbackPanel = modalWindow.get(errorMsg); FormTester formTester = tester.newFormTester(loginForm.getPageRelativePath() + : + loginForm.getId()); but I have a java.lang.NullPointerException on loginForm (and feedbackPanel is also null). I begin with Wiket and I really don't understand why it doesn't work. What am I doing wrong? Thanks Mathilde
Re: problem to test form in modal window with wicket tester
Hi Mathilde, maybe the form id you use in test is not correct. How do you add form to modalWindow? Can you attach code? Hi all, I have a modal window with a login form inside that works fine when I test it manually. I try to test it with wicket tester since yesterday. I saw in some mails of this list that there is nothing special in testing modal windows. I tried this : tester.startPage(AccueilPage.class); tester.clickLink(connexion); ModalWindowE4N modalWindow = (ModalWindowE4N) tester.getComponentFromLastRenderedPage(modalConnexion); tester.isVisible(modalWindow.getPageRelativePath() + : + modalWindow.getContentId()); Form? loginForm = (Form?) modalWindow.get(loginForm); Component feedbackPanel = modalWindow.get(errorMsg); FormTester formTester = tester.newFormTester(loginForm.getPageRelativePath() + : + loginForm.getId()); but I have a java.lang.NullPointerException on loginForm (and feedbackPanel is also null). I begin with Wiket and I really don't understand why it doesn't work. What am I doing wrong? Thanks Mathilde - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: problem to test form in modal window with wicket tester
this is the code to construct modal window final ModalWindowE4N modalConnexion = new ModalWindowE4N(modalConnexion); modalConnexion.setTitle(Connexion à l'espace membre); modalConnexion.setContent(new ConnexionContentPanel(modalConnexion.getContentId())); add(modalConnexion); Form is added in ConnexionContentPanel : public ConnexionContentPanel(String id) { super(id); //Création du formulaire dont les champs seront liés aux champs d'un membre grace au model FormMembre loginForm = new FormMembre(loginForm, new CompoundPropertyModelMembre(new LoadableDetachableModelMembre() { @Override protected Membre load() { return new Membre(); } })); //Création et ajout des champs id et pwd au formulaire TextFieldMembre idField = new TextFieldMembre(membreId); idField.setRequired(true); loginForm.add(idField); PasswordTextField pwdField = new PasswordTextField(password); pwdField.setRequired(true); loginForm.add(pwdField); //Ajout d'un du feedback panel qui contiendra les erreurs relevées par le formulaire final FeedbackPanel feedBackPanel = new FeedbackPanel(errorMsg); feedBackPanel.setOutputMarkupId(true); add(feedBackPanel); //création du bouton ajax pour soumettre le formulaire AjaxButton submitbutton = new AjaxButton(ajaxSubmitLogin) { @Override protected void onSubmit(AjaxRequestTarget target, Form? form) { Membre modelObject = (Membre) form.getModelObject(); Membre membre; membre = serviceIdentif.identifier(modelObject.getId(), modelObject.getPassword()); if(membre == null) error(Identifiant ou mot de passe incorrect); else setResponsePage(TableauBordPage.class); } @Override protected void onError(AjaxRequestTarget target, Form? form) { target.addComponent(feedBackPanel); } }; loginForm.add(submitbutton); //ajout du formulaire au panel add(loginForm); } you can see that form id is correct. It is the same problem with FeedBackPanel errorMsg : I get a null pointer when I try to get it with modalWindow.get(errorMsg); 2011/5/26 Andrea Del Bene adelb...@ciseonweb.it Hi Mathilde, maybe the form id you use in test is not correct. How do you add form to modalWindow? Can you attach code? Hi all, I have a modal window with a login form inside that works fine when I test it manually. I try to test it with wicket tester since yesterday. I saw in some mails of this list that there is nothing special in testing modal windows. I tried this : tester.startPage(AccueilPage.class); tester.clickLink(connexion); ModalWindowE4N modalWindow = (ModalWindowE4N) tester.getComponentFromLastRenderedPage(modalConnexion); tester.isVisible(modalWindow.getPageRelativePath() + : + modalWindow.getContentId()); Form? loginForm = (Form?) modalWindow.get(loginForm); Component feedbackPanel = modalWindow.get(errorMsg); FormTester formTester = tester.newFormTester(loginForm.getPageRelativePath() + : + loginForm.getId()); but I have a java.lang.NullPointerException on loginForm (and feedbackPanel is also null). I begin with Wiket and I really don't understand why it doesn't work. What am I doing wrong? Thanks Mathilde - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Mathilde Pellerin Ingénieur en Génie Logiciel Tél mobile : 06.60.78.79.03 E-mail : mathilde.pelle...@gmail.com Mon CV en ligne : http://www.mathilde-pellerin.fr/ http://www.mathilde-pellerin.fr/Mes liens : http://www.viadeo.com/fr/profile/mathilde.pellerin http://fr.linkedin.com/in/mathildepellerin
Re: problem to test form in modal window with wicket tester
It's fix : when I paste code to show you, I notice that login form is not added in modal window but in ConnexionContentPanel... So I try this code : ModalWindowE4N modalWindow = (ModalWindowE4N) tester.getComponentFromLastRenderedPage(modalConnexion); ConnexionContentPanel loginPanel = (ConnexionContentPanel) modalWindow.get(modalWindow.getContentId()); Form? loginForm = (Form?) loginPanel.get(loginForm); FormTester formTester = tester.newFormTester(loginForm.getPageRelativePath()); and it works. Thanks for your help. 2011/5/26 Mathilde Pellerin mathilde.pelle...@gmail.com this is the code to construct modal window final ModalWindowE4N modalConnexion = new ModalWindowE4N(modalConnexion); modalConnexion.setTitle(Connexion à l'espace membre); modalConnexion.setContent(new ConnexionContentPanel(modalConnexion.getContentId())); add(modalConnexion); Form is added in ConnexionContentPanel : public ConnexionContentPanel(String id) { super(id); //Création du formulaire dont les champs seront liés aux champs d'un membre grace au model FormMembre loginForm = new FormMembre(loginForm, new CompoundPropertyModelMembre(new LoadableDetachableModelMembre() { @Override protected Membre load() { return new Membre(); } })); //Création et ajout des champs id et pwd au formulaire TextFieldMembre idField = new TextFieldMembre(membreId); idField.setRequired(true); loginForm.add(idField); PasswordTextField pwdField = new PasswordTextField(password); pwdField.setRequired(true); loginForm.add(pwdField); //Ajout d'un du feedback panel qui contiendra les erreurs relevées par le formulaire final FeedbackPanel feedBackPanel = new FeedbackPanel(errorMsg); feedBackPanel.setOutputMarkupId(true); add(feedBackPanel); //création du bouton ajax pour soumettre le formulaire AjaxButton submitbutton = new AjaxButton(ajaxSubmitLogin) { @Override protected void onSubmit(AjaxRequestTarget target, Form? form) { Membre modelObject = (Membre) form.getModelObject(); Membre membre; membre = serviceIdentif.identifier(modelObject.getId(), modelObject.getPassword()); if(membre == null) error(Identifiant ou mot de passe incorrect); else setResponsePage(TableauBordPage.class); } @Override protected void onError(AjaxRequestTarget target, Form? form) { target.addComponent(feedBackPanel); } }; loginForm.add(submitbutton); //ajout du formulaire au panel add(loginForm); } you can see that form id is correct. It is the same problem with FeedBackPanel errorMsg : I get a null pointer when I try to get it with modalWindow.get(errorMsg); 2011/5/26 Andrea Del Bene adelb...@ciseonweb.it Hi Mathilde, maybe the form id you use in test is not correct. How do you add form to modalWindow? Can you attach code? Hi all, I have a modal window with a login form inside that works fine when I test it manually. I try to test it with wicket tester since yesterday. I saw in some mails of this list that there is nothing special in testing modal windows. I tried this : tester.startPage(AccueilPage.class); tester.clickLink(connexion); ModalWindowE4N modalWindow = (ModalWindowE4N) tester.getComponentFromLastRenderedPage(modalConnexion); tester.isVisible(modalWindow.getPageRelativePath() + : + modalWindow.getContentId()); Form? loginForm = (Form?) modalWindow.get(loginForm); Component feedbackPanel = modalWindow.get(errorMsg); FormTester formTester = tester.newFormTester(loginForm.getPageRelativePath() + : + loginForm.getId()); but I have a java.lang.NullPointerException on loginForm (and feedbackPanel is also null). I begin with Wiket and I really don't understand why it doesn't work. What am I doing wrong? Thanks Mathilde - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Mathilde Pellerin Ingénieur en Génie Logiciel Tél mobile : 06.60.78.79.03 E-mail : mathilde.pelle...@gmail.com Mon CV en ligne : http://www.mathilde-pellerin.fr/ http://www.mathilde-pellerin.fr/Mes liens : http://www.viadeo.com/fr/profile/mathilde.pellerin http://fr.linkedin.com/in/mathildepellerin -- Mathilde Pellerin Ingénieur en Génie Logiciel Tél mobile : 06.60.78.79.03 E-mail : mathilde.pelle...@gmail.com Mon CV en
Re: problem to test form in modal window with wicket tester
Form id is corret, but remember that form and feedback panel are not added directly to modal window. They are inside ConnexionContentPanel which in turn is added to modalwindow. In your test you should be able to access form calling getContent() before get(loginForm), i.e: modalWindow.getContent().get(loginForm) this is the code to construct modal window final ModalWindowE4N modalConnexion = new ModalWindowE4N(modalConnexion); modalConnexion.setTitle(Connexion à l'espace membre); modalConnexion.setContent(new ConnexionContentPanel(modalConnexion.getContentId())); add(modalConnexion); Form is added in ConnexionContentPanel : public ConnexionContentPanel(String id) { super(id); //Création du formulaire dont les champs seront liés aux champs d'un membre grace au model FormMembre loginForm = new FormMembre(loginForm, new CompoundPropertyModelMembre(new LoadableDetachableModelMembre() { @Override protected Membre load() { return new Membre(); } })); //Création et ajout des champs id et pwd au formulaire TextFieldMembre idField = new TextFieldMembre(membreId); idField.setRequired(true); loginForm.add(idField); PasswordTextField pwdField = new PasswordTextField(password); pwdField.setRequired(true); loginForm.add(pwdField); //Ajout d'un du feedback panel qui contiendra les erreurs relevées par le formulaire final FeedbackPanel feedBackPanel = new FeedbackPanel(errorMsg); feedBackPanel.setOutputMarkupId(true); add(feedBackPanel); //création du bouton ajax pour soumettre le formulaire AjaxButton submitbutton = new AjaxButton(ajaxSubmitLogin) { @Override protected void onSubmit(AjaxRequestTarget target, Form? form) { Membre modelObject = (Membre) form.getModelObject(); Membre membre; membre = serviceIdentif.identifier(modelObject.getId(), modelObject.getPassword()); if(membre == null) error(Identifiant ou mot de passe incorrect); else setResponsePage(TableauBordPage.class); } @Override protected void onError(AjaxRequestTarget target, Form? form) { target.addComponent(feedBackPanel); } }; loginForm.add(submitbutton); //ajout du formulaire au panel add(loginForm); } you can see that form id is correct. It is the same problem with FeedBackPanel errorMsg : I get a null pointer when I try to get it with modalWindow.get(errorMsg); - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: problem to test form in modal window with wicket tester
I didn't find getContent() method to modalWindow component, but it works well in two steps : ConnexionContentPanel loginPanel = (ConnexionContentPanel) modalWindow.get(modalWindow.getContentId()); Form? loginForm = (Form?) loginPanel.get(loginForm); thanks a lot ! 2011/5/26 Andrea Del Bene adelb...@ciseonweb.it Form id is corret, but remember that form and feedback panel are not added directly to modal window. They are inside ConnexionContentPanel which in turn is added to modalwindow. In your test you should be able to access form calling getContent() before get(loginForm), i.e: modalWindow.getContent().get(loginForm) this is the code to construct modal window final ModalWindowE4N modalConnexion = new ModalWindowE4N(modalConnexion); modalConnexion.setTitle(Connexion à l'espace membre); modalConnexion.setContent(new ConnexionContentPanel(modalConnexion.getContentId())); add(modalConnexion); Form is added in ConnexionContentPanel : public ConnexionContentPanel(String id) { super(id); //Création du formulaire dont les champs seront liés aux champs d'un membre grace au model FormMembre loginForm = new FormMembre(loginForm, new CompoundPropertyModelMembre(new LoadableDetachableModelMembre() { @Override protected Membre load() { return new Membre(); } })); //Création et ajout des champs id et pwd au formulaire TextFieldMembre idField = new TextFieldMembre(membreId); idField.setRequired(true); loginForm.add(idField); PasswordTextField pwdField = new PasswordTextField(password); pwdField.setRequired(true); loginForm.add(pwdField); //Ajout d'un du feedback panel qui contiendra les erreurs relevées par le formulaire final FeedbackPanel feedBackPanel = new FeedbackPanel(errorMsg); feedBackPanel.setOutputMarkupId(true); add(feedBackPanel); //création du bouton ajax pour soumettre le formulaire AjaxButton submitbutton = new AjaxButton(ajaxSubmitLogin) { @Override protected void onSubmit(AjaxRequestTarget target, Form? form) { Membre modelObject = (Membre) form.getModelObject(); Membre membre; membre = serviceIdentif.identifier(modelObject.getId(), modelObject.getPassword()); if(membre == null) error(Identifiant ou mot de passe incorrect); else setResponsePage(TableauBordPage.class); } @Override protected void onError(AjaxRequestTarget target, Form? form) { target.addComponent(feedBackPanel); } }; loginForm.add(submitbutton); //ajout du formulaire au panel add(loginForm); } you can see that form id is correct. It is the same problem with FeedBackPanel errorMsg : I get a null pointer when I try to get it with modalWindow.get(errorMsg); - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Mathilde Pellerin Ingénieur en Génie Logiciel Tél mobile : 06.60.78.79.03 E-mail : mathilde.pelle...@gmail.com Mon CV en ligne : http://www.mathilde-pellerin.fr/ http://www.mathilde-pellerin.fr/Mes liens : http://www.viadeo.com/fr/profile/mathilde.pellerin http://fr.linkedin.com/in/mathildepellerin
Re: problem to test form in modal window with wicket tester
Sorry, I didn't noticed that getContent() is protected. The solution you found is perfect :-) I didn't find getContent() method to modalWindow component, but it works well in two steps : ConnexionContentPanel loginPanel = (ConnexionContentPanel) modalWindow.get(modalWindow.getContentId()); Form? loginForm = (Form?) loginPanel.get(loginForm); thanks a lot ! 2011/5/26 Andrea Del Beneadelb...@ciseonweb.it - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org