Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Apache%20Wicket%20Interview%20Questions%20and%20Answers

Question: How to keep file validation in apache-wicket if no file has been selected?
Answer:
To fix it, just override the validateOnNullValue() method like this :

FileUploadField fileUpload = new FileUploadField("fileupload",new Model<FileUpload>());
 
fileUpload .add(new AbstractValidator() { 
 
       public boolean validateOnNullValue(){
       return true;
}
 
protected void onValidate(IValidatable validatable) { 
FileUpload fileUpload = (FileUpload) validatable.getValue();
}
 
    protected String resourceKey() {
   return "yourErrorKey";
}
 
});
Now, when no file is selected, and submit button is clicked, validation will be performed.
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook