Hi!
I have an abstract domain class called Item extended by many class.
I wanto to have only one Dao / Service / Controller that handle all classes that extend Item.
My dao and my service work ok.
My problem is on controller:
I can create FORM for create update and show returning the correct view based on the instance type returned from service given Item id.
But i cannot save or modify Item object, because when I call for instance the create method:
I got the following exception:Code:@RequestMapping(method = RequestMethod.POST) public String create(final Item item, final BindingResult bindingResult, final Model uiModel, final HttpServletRequest httpServletRequest) { if (bindingResult.hasErrors()) { ... } uiModel.asMap().clear(); itemService.saveItem(item); return "redirect:/item/" + UrlUtil.encodeUrlPathSegment(attrezzatura.getId().toString(), httpServletRequest); }
Could not instantiate bean class [...Item]: Is it an abstract class?; nested exception is java.lang.InstantiationException
How can I bind Abstract class to correct Concrete class?
I think I can do it in init binder.. but I have no idea on how to do it!
Thank you!!
Marco


Reply With Quote
