Пример #1
0
  // Business logic validation
  public void uniqueName(FacesContext context, UIComponent component, Object value) {

    String name = (String) value;

    for (Sweter sweter : sm.getAllSweters()) {
      if (sweter.getName().equalsIgnoreCase(name)) {
        FacesMessage message = new FacesMessage("Sweter with this name already exists in database");
        message.setSeverity(FacesMessage.SEVERITY_ERROR);
        throw new ValidatorException(message);
      }
    }
    /*for (Person person : pm.getAllPersons()) {
    	if (person.getPin().equalsIgnoreCase(pin)) {
    		FacesMessage message = new FacesMessage(
    				"Person with this PIN already exists in database");
    		message.setSeverity(FacesMessage.SEVERITY_ERROR);
    		throw new ValidatorException(message);
    	}
    }*/
  }
Пример #2
0
 // Actions
 public String addSweter() {
   sm.addSweter(sweter);
   return "showSweters";
   // return null;
 }
Пример #3
0
 public String deleteSweter() {
   Sweter sweterToDelete = sweters.getRowData();
   sm.deleteSweter(sweterToDelete);
   return null;
 }
Пример #4
0
 public ListDataModel<Sweter> getAllSweters() {
   sweters.setWrappedData(sm.getAllSweters());
   return sweters;
 }