Announcement Announcement Module
Collapse
No announcement yet.
Adding enctype="multipart/form-data" to form tag causes problem with update Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    This reference might help you http://viralpatel.net/blogs/2011/02/...-tutorial.html.


    B Roogards
    jD

    Comment


    • #3
      thank you for the answer

      Code:
       I am not allowing updates in this version of the application. So, I disabled it, by setting the update=false in the @RooWebScaffold annotation.
      I will do the same, although it's a workaround, for now, until I figure it out, it will do fine

      Comment

      Working...
      X