I posted another topic about collection having a NullPointerException. I tried to fix the FormFile by getting info from collections. it doesn't work by having -
private FormFile sheet = new FormFile();
- doesn't work
private FormFile sheet = null;
- I have this set up.
I check the validation of this -
if (getSheet() == null || getSheet().getFileSize() < 1) {
errors.add("type", new ActionMessage("errors.sheetnull"));
String contentType = getSheet().getContentType();
if (!( contentType.equals("application/pdf") || contentType.equals("text/plain") || contentType.equals("image/jpeg")
|| contentType.equals("image/gif") || contentType.equals("image/png"))) {
errors.add("sheet", new ActionMessage("errors.sheet"));
}
I have a string for the search engine, and when I submit, it returns the NullPointerException, although the upload formfile is for adding a document. Both functions are in a same form. Any suggestions? I might have to make a separate form for each function. Just want to know what's a right code practice or a solution to this.