/** 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")); } } }
/** * Méthode permettant d'afficher la liste des salles * * @return */ @SkipValidation public String showClassroom() { forward = FORWARD_SUCCESS; this.listClassroomBean = new ArrayList<ClassroomBean>(); try { List<ClassroomEntity> listClassroomEntity = cdao.getAll(); for (ClassroomEntity classroomEntity : listClassroomEntity) { ClassroomBean classroomBean = new ClassroomBean(); classroomBean.setId(classroomEntity.getId()); classroomBean.setName(classroomEntity.getName()); this.listClassroomBean.add(classroomBean); } } catch (Exception e) { forward = generateError(e); } return forward; }
/** 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; }