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 <[email protected]>
>
>
> 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
> Form<Membre> loginForm = new Form<Membre>("loginForm",
> new CompoundPropertyModel<Membre>(new
> LoadableDetachableModel<Membre>() {
>
> @Override
> protected Membre load() {
> return new Membre();
> }
> }));
>
> //Création et ajout des champs id et pwd au formulaire
> TextField<Membre> idField = new TextField<Membre>("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 <[email protected]>
>
>> 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: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
>
> --
> Mathilde Pellerin Ingénieur en Génie Logiciel Tél mobile :
> 06.60.78.79.03 E-mail : [email protected] 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
: [email protected] 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>