throws Exception {
if (log.isDebugEnabled()) {
log.debug("entering 'onSubmit' method...");
}
DefectRecomendation defectRecomendation = (DefectRecomendation) command;
boolean isNew = (defectRecomendation.getDefectRecomendationId() == null);
Locale locale = request.getLocale();
if (request.getParameter("delete") != null) {
defectRecomendationManager.removeDefectRecomendation(defectRecomendation.getDefectRecomendationId().toString());
saveMessage(request, getText("defectRecomendation.deleted", locale));
} else {
Integer defectCategoryId = defectRecomendation.getDefectCategory().getDefectCategoryId();
if (!defectCategoryId.equals(new Integer(-1))) {
defectRecomendation.setDefectCategory(defectCategoryManager.getDefectCategory(defectCategoryId.toString()));
}
defectRecomendation.setConstructionType(constructionTypeManager.getConstructionType(defectRecomendation.getDefectCategory().getConstructionType().getConstructionTypeId().toString()));
// Integer constructionTypeId = defectRecomendation.getConstructionType().getConstructionTypeId();
// if (!constructionTypeId.equals(new Integer(-1))) {
// defectRecomendation.setConstructionType(constructionTypeManager.getConstructionType(constructionTypeId.toString()));
// }
defectRecomendationManager.saveDefectRecomendation(defectRecomendation);
String key = (isNew) ? "defectRecomendation.added" : "defectRecomendation.updated";
saveMessage(request, getText(key, locale));
if (defectRecomendation.isEdited()) {
return new ModelAndView("redirect:updating.html?id=" + defectRecomendation.getDefectRecomendationId() + "&fieldId=" + request.getParameter("fieldId"));
}
}
return new ModelAndView("redirect:" + defectRecomendation.getDocLocation());
}