PDA

View Full Version : BindException


Lord0
Apr 27th, 2006, 07:05 AM
Hi there,

When I attempt to validate a form submission I am receiving the following error:

"Could not instantiate class [org.springframework.validation.BindException]: no default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.validation.BindException.()"

I am using a MultiActionController (CalendarController.java), inside which:

public CalendarController()
{
setValidators(new Validator [] {CalendarEventValidator()});
}

i have a method which "submits" a new event...

public ModelAndView submitCalendarEvent(HttpServletRequest request, HttpServletResponse response,
CalenderEvent command, BindException errors) throws Exception
{


m_calendarManager.insertNewCalendarEvent(command);

Map myModel = getDayPageModelData(command);

myModel.put("message", "Calendar Event added.");

ModelAndView mv = new ModelAndView("day", errors.getModel());

mv.addObject("model", myModel);
mv.addObject("calenderEvent", command);

return mv;
}

I am unsure what is going wrong.

Notes:
I know the validator class is successfully being called as if I change the method signature to:

public ModelAndView submitCalendarEvent(HttpServletRequest request, HttpServletResponse response,
CalenderEvent command)

i.e. remove the errors

then in my jsp I get:
Errors binding onto object 'command'; nested exception is org.springframework.validation.BindException: BindException: 4 errors; Field error in object 'command' on field 'shortDescription': rejected value []; codes [required.shortDescription.command.shortDescription ,required.shortDescription.shortDescription,requir ed.shortDescription.java.lang.String,required.shor tDescription]; arguments []; default message [Short Description is a required field]; Field error in object 'command' on field 'longDescription': rejected value []; codes [required.longDescription.command.longDescription,r equired.longDescription.longDescription,required.l ongDescription.java.lang.String,required.longDescr iption]; arguments []; default message [Long Description is a required field]; Field error in object 'command' on field 'startDateTime': rejected value [Please select...]; codes [required.startDateTime.command.startDateTime,requi red.startDateTime.startDateTime,required.startDate Time.java.lang.String,required.startDateTime]; arguments []; default message [Start Time is a required field.]; Field error in object 'command' on field 'endDateTime': rejected value [Please select...]; codes [required.endDateTime.command.endDateTime,required. endDateTime.endDateTime,required.endDateTime.java. lang.String,required.endDateTime]; arguments []; default message [End Time is a required field.]

I can post any other code, files you may need

cheers

Lord0