throws Exception {
if (log.isDebugEnabled()) {
log.debug("entering 'onSubmit' method...");
}
ConstructionType constructionType = (ConstructionType) command;
boolean isNew = (constructionType.getConstructionTypeId() == null);
Locale locale = request.getLocale();
if (request.getParameter("delete") != null) {
constructionTypeManager.removeConstructionType(constructionType.getConstructionTypeId().toString());
saveMessage(request, getText("constructionType.deleted", locale));
} else {
Integer materialId = constructionType.getMaterial().getMaterialId();
if (!materialId.equals(new Integer(-1))) {
constructionType.setMaterial(materialManager.getMaterial(materialId.toString()));
}
List defectZoneListFromForm = constructionType.getDefectZones();
List defectZoneListToBase = new ArrayList();
for (int i = 0; i < defectZoneListFromForm.size(); i++) {
DefectZone defectZone = (DefectZone) defectZoneListFromForm.get(i);
Integer defectZoneId = defectZone.getDefectZoneId();
if (!defectZoneId.equals(new Integer(-1))) {
defectZoneListToBase.add(defectZoneManager.getDefectZone(defectZoneId.toString()));
}
}
constructionType.setDefectZones(defectZoneListToBase);
constructionTypeManager.saveConstructionType(constructionType);
String key = (isNew) ? "constructionType.added" : "constructionType.updated";
saveMessage(request, getText(key, locale));
if (constructionType.isEdited()) {
return new ModelAndView("redirect:updating.html?id=" + constructionType.getConstructionTypeId() + "&fieldId=" + request.getParameter("fieldId"));
}
return new ModelAndView("redirect:" + constructionType.getDocLocation());
}
return new ModelAndView("redirect:" + constructionType.getDocLocation());
}