// 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); } }*/ }
// Actions public String addSweter() { sm.addSweter(sweter); return "showSweters"; // return null; }
public String deleteSweter() { Sweter sweterToDelete = sweters.getRowData(); sm.deleteSweter(sweterToDelete); return null; }
public ListDataModel<Sweter> getAllSweters() { sweters.setWrappedData(sm.getAllSweters()); return sweters; }