Which version of Wicket ? Looking at both 1.4.x and 1.5-SNAPSHOT code I think validation should be executed. 1.5 code is much cleaner ...
On Thu, Aug 18, 2011 at 11:26 AM, Mathilde Pellerin <[email protected]> wrote: > little precision : it the same thing for file size validation. > I have a maxSize to my form : > form.setMaxSize(Bytes.kilobytes(50)); > > when I test it manually, I have error message, but not when I test it by > wicketTester and formTester... > I don't understand what I forgot or what I doing wrong in my test. > > > > 2011/8/18 Mathilde Pellerin <[email protected]> > >> Hi all, >> >> I have a little problem to test a form in my application. >> I have a FileUploadField with an abstractValidator like that : >> FileUploadField fuploadField = new >> FileUploadField("uploadImage", new Model<FileUpload>()); >> fuploadField.add(new AbstractValidator<FileUpload>() { >> @Override >> protected void onValidate(IValidatable<FileUpload> >> validatable) { >> System.err.println("Passage dans le validateur"); >> FileUpload fupload = (FileUpload) >> validatable.getValue(); >> if(fupload != null){ >> if(fupload.getSize() == 0){ >> error(validatable); >> } >> else >> if(!Utils.checkContentType(fupload.getContentType())){ >> error(validatable); >> } >> } >> } >> }); >> >> when I test manually this form with wrong image type, validation works >> well. >> I try to test this validator with wicketTester like that : >> @Test @Transactional @Rollback >> public void testStory23_TA13(){ >> tester.startPage(CreationQuestionnairePage.class); >> tester.assertRenderedPage(CreationQuestionnairePage.class); >> >> String titre = "nouveau questionnaire"; >> FormTester formTester = >> tester.newFormTester("formCreationQuestionnaire"); >> formTester.setValue("titre", titre); >> formTester.setValue("numero", "10"); >> formTester.select("sexeDestinataire", 0); >> >> formTester.setValue("conteneurQuestions:question:1:texteQuestion", >> "question 1"); >> formTester.setValue("conteneurQuestions:question:1:legende", >> "legende question 1"); >> formTester.setValue("conteneurQuestions:question:1:uploadImage", >> "/Users/mathildepellerin/Desktop/moto.JPG"); >> formTester.submit(); >> >> tester.assertErrorMessages(new String[]{"Question 1 : Image trop >> volumineuse. La taille des images est limitée à 50k."}); >> } >> >> but onValidate() method of my validator is never called. >> It's not an ajax form, and I can check error messages send by required >> fields without any problem. >> Is there something else to do to test our own validator? >> >> Thanks. >> M. >> >> -- >> *Mathilde Pellerin* >> Ingénieur en développement de logiciel >> >> STATLIFE >> tel : 01.42.11.64.88 >> mail : [email protected] >> >> >> >> > > > -- > *Mathilde Pellerin* > Ingénieur en développement de logiciel > > STATLIFE > tel : 01.42.11.64.88 > mail : [email protected] > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
