示例#1
0
 @Override
 public String save() {
   boolean ok = true;
   if (getElement().getName() == null || getElement().getName().trim().isEmpty()) {
     super.addFacesMessage("Nome della proprieta' non specificato");
     ok = false;
   }
   if (getElement().getOption() == null || getElement().getOption().trim().isEmpty()) {
     super.addFacesMessage("Nome dell'opzione non specificato");
     ok = false;
   }
   if (!ok) {
     return null;
   }
   getElement().setName(getElement().getName().trim());
   getElement().setOption(getElement().getOption().trim());
   for (String option : propertyRepository.getOptions(getElement().getName().trim())) {
     if (option != null && option.trim().equals(getElement().getOption())) {
       super.addFacesMessage("Opzione gia' presente");
       ok = false;
       break;
     }
   }
   if (!ok) {
     return null;
   }
   if (super.save() == null) {
     return null;
   }
   setElement(new Feature());
   return listPage();
 }
示例#2
0
 @Override
 public Feature getElement() {
   if (super.getElement() == null) {
     super.setElement(new Feature());
   }
   return super.getElement();
 }
示例#3
0
 @Override
 public void onRowEdit(RowEditEvent ree) {
   Feature property = (Feature) ree.getObject();
   if (property.getOptionOnDb().equals(property.getOption())) {
     return;
   }
   property.setName(property.getName().trim());
   property.setOption(property.getOption().trim());
   for (String option : propertyRepository.getOptions(property.getName().trim())) {
     if (option != null && option.trim().equals(property.getOption())) {
       super.addFacesMessage(
           FacesMessage.SEVERITY_ERROR, "Opzione gia' presente", "", "featuresList");
       property.setOption(property.getOptionOnDb());
       return;
     }
   }
   super.onRowEdit(ree);
 }