return result;
}
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
EmployeeView view = (EmployeeView) command;
IOffice office = view.getOffice();
if (store.getEmployee(view.getMatriculationCode()) != null) {
errors.rejectValue("matriculationCode", EmployeeErrorCodes.DUPLICATED_CODE, "Duplicated Matriculation Code!");
return this.showForm(request, response, errors);
}
if (office == null) {
errors.rejectValue("office", OfficeErrorCodes.NOT_FOUND, "No office found!");
return this.showForm(request, response, errors);
}
else {
try {
IEmployee employee = (IEmployee) this.introductor.getTarget(view);
office.addEmployee(employee);
store.addOffice(office);
}
catch(BusinessException ex) {
for (Error error : ex.getErrors()) {
errors.reject(error.getCode(), error.getMessage());