/** * Creates a comment and redirects back to the recipe page * * @return the string navigation outcome */ public String doCreateComment() { Users commenter = ui.getUser(); try { this.newComment.setRecipe(this.recipe); this.newComment.setCommenter(commenter); this.newComment.setDateCommented(new Date().getTime()); List<Comment> c = recipe.getComments(); c.add(newComment); this.recipe.setComments(c); recipesEJB.editRecipe(recipe); } catch (javax.ejb.EJBAccessException ejbae) { FacesContext.getCurrentInstance() .addMessage(null, new FacesMessage("Only registered users can post comments.")); } return "/recipe.xhtml?recipe=" + qm.get("recipe"); }