示例#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;
 }