Ejemplo n.º 1
0
 public void onrate(RateEvent rateEvent) {
   FacesMessage message =
       new FacesMessage(
           FacesMessage.SEVERITY_INFO,
           "Rate Event",
           "You rated:" + ((Integer) rateEvent.getRating()).intValue());
   FacesContext.getCurrentInstance().addMessage(null, message);
 }
Ejemplo n.º 2
0
  public void onrate(RateEvent rateEvent) {

    HttpSession session = FacesUtil.getSession();
    User user = (User) session.getAttribute("user");

    Rating userRating = getUserRating(user);

    int score = ((Integer) rateEvent.getRating()).intValue();
    Rating rate = new Rating();
    rate.setRating(score);
    rate.setRecipe(recipe);
    rate.setUserId(user);

    if (userRating == null) {
      serviceRating.create(rate);
    } else {
      rate.setId(userRating.getId());
      serviceRating.update(rate);
    }
  }