/** * Queries the UIData for the current row of data to get the current cheese. * * @return String for the cheese name. * @throws NullPointerException if the rowdata returns a null Cheese. */ private String getSelectedCheeseName() { Cheese cheese = (Cheese) cheeseList.getRowData(); // make sure it still exists if (cheese == null) { throw new NullPointerException("cheese"); } return cheese.getName(); }
public String removeCheese() { Cheese tempCheese = new Cheese(getSelectedCheeseName(), ""); Cheese storedCheese = service.find(tempCheese); if (storedCheese == null) { FacesContext.getCurrentInstance() .addMessage(null, new FacesMessage("Cheese " + tempCheese.getName() + " Not Found!")); return "delete error"; } service.remove(storedCheese); FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Cheese Removed")); return "ok"; }
public void remove(Cheese cheese) { cheeses.remove(cheese.getName()); }
public void save(Cheese cheese) { cheeses.put(cheese.getName(), cheese); }