/** Méthode permetant la validation des champs */ public void validate() { if (classroomBean != null) { if (classroomBean.getName().isEmpty()) { addFieldError("error.name", getText("validator.field.empty")); } if (!classroomBean.getName().equals(session.get(OLD_VALUE))) { if (cdao.existNameClassroom(classroomBean.getName())) addFieldError("error.name", getText("validator.classroom.exist")); } } }
/** Execution la sauvegarde d'une salle */ public String execute() { forward = FORWARD_SUCCESS; try { ClassroomEntity c = new ClassroomEntity(); c.setName(classroomBean.getName()); cdao.save(c); } catch (Exception e) { forward = generateError(e); } return forward; }