Пример #1
0
  @Security.Authenticated(Secured.class)
  public static Result addNewMessageForm(Long id) {
    Form<MessageForm> mesForm = Form.form(MessageForm.class).bindFromRequest();
    if (mesForm.hasErrors()) {
      return badRequest(postNewMessage.render(mesForm, id));
    } else {

      Message m =
          new Message(
              mesForm.field("text").value().toString(), Student.find.byId(request().username()));

      Conversation c = null;

      c = Conversation.find.byId(id.toString());
      c.messages.add(m);
      c.save();

      return redirect(routes.Application.viewMyConversation(id));
    }
  }
Пример #2
0
 @Security.Authenticated(Secured.class)
 public static Result addNewMessage(Long id) {
   return redirect(
       //                postNewMessage.render(form(MessageForm.class), id)
       routes.Application.viewMyConversation(id));
 }