Adding enctype="multipart/form-data" to form tag causes problem with update
Hi,
I'm adding support for file upload. I've added enctype="multipart/form-data" to a form tag and it's breaking update CRUD operation.
I've changed update.tagx from
Code:
<form:form action="${fn:escapeXml(form_url)}" method="PUT" modelAttribute="${modelAttribute}">
to
Code:
<form:form action="${fn:escapeXml(form_url)}" method="PUT" modelAttribute="${modelAttribute}" enctype="multipart/form-data" >
Now, When I'm trying to edit entitity with Roo generated form, it's causing hibernate unhandled exception, unable to persist detached object.
After debugging, I've discovered that instead of update method
Code:
@RequestMapping(method = RequestMethod.PUT)
public String TipLokacijeController.update(@Valid TipLokacije tipLokacije, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
if (bindingResult.hasErrors()) {
uiModel.addAttribute("tipLokacije", tipLokacije);
return "tiplokacijes/update";
}
uiModel.asMap().clear();
tipLokacije.merge();
return "redirect:/tiplokacijes/" + encodeUrlPathSegment(tipLokacije.getId().toString(), httpServletRequest);
}
create method is being called,
Code:
@RequestMapping(method = RequestMethod.POST)
public String TipLokacijeController.create(@Valid TipLokacije tipLokacije, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
if (bindingResult.hasErrors()) {
uiModel.addAttribute("tipLokacije", tipLokacije);
return "tiplokacijes/create";
}
uiModel.asMap().clear();
tipLokacije.persist();
return "redirect:/tiplokacijes/" + encodeUrlPathSegment(tipLokacije.getId().toString(), httpServletRequest);
}
How can I add support for file upload without breaking "update" CRUD operation
Thank you for your answers