Ejemplo n.º 1
0
  /**
   * 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();
  }
Ejemplo n.º 2
0
  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";
  }
Ejemplo n.º 3
0
 public void remove(Cheese cheese) {
   cheeses.remove(cheese.getName());
 }
Ejemplo n.º 4
0
 public void save(Cheese cheese) {
   cheeses.put(cheese.getName(), cheese);
 }