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); }
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); } }