I need to edit a form that also has an image attribute of type blob. Whenever I edit the form and submit it, it shows me the error page catching a java.lang.NullPointerException but the data is actually being persisted in the database and it is also showing in the view. I need the submit button to redirect me to another page and I cannot achieve that.
This is my edit form method:
@Transactional
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
public String updateEmployeeProfile(@PathVariable("id")int id, @RequestParam("profilePicture") MultipartFile file,
@RequestParam("name") String name,
@RequestParam("birthDate") String birthDate,
@RequestParam("address") String address,
@RequestParam("phone") String phone,
@RequestParam("email") String email,
@RequestParam("designation") String designation,
@RequestParam("jobDescription") String jobDescription){
employee employee = em.find(com.techflakes.advocatoree.model.employee.class, id);
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
try {
employee.setName(name);
employee.setProfilePicture(file.getBytes());
employee.setAddress(address);
employee.setBirthDate(sdf.parse(birthDate));
employee.setDesignation(designation);
employee.setEmail(email);
employee.setJobDescription(jobDescription);
employee.setPhone(phone);
if (employee.getCurrent().equals("Yes")) {
employee.setCurrentemployee(true);
} else {
employee.setCurrentemployee(false);
}
}catch (Exception ex)
{
System.out.println(ex);
return "redirect:/advocatoree/error";
}
em.persist(employee);
return "redirect:/advocatoree/manageEmployee/browseEmployees";
}
What should I do?
Aucun commentaire:
Enregistrer un commentaire