Hi all,
While I was working on a project I had to save large content of data from text area filed in a form.
I'm using Play Framework 2.0.2 as a web framework and using scala html templates as views.
I have text area filed in my form to add html data (Actually here I'm using ace.js that is high quality code editor. Ill give brief introduction to ace later).
Ok Here I do not post form binding with model class but just think that there is a simple model class lets say Page. Most important thing is the saving part of this program. Here I have posted my save definition(function).
Important part of the above code snippet is
parse.urlFormEncoded(maxLength = 1024 * 1000)
It accepts 1000 KB of data. default length is 100 KB. I have to save 600KB of data (from text area) and without above code browser is hanging and data is not saved and ultimately browser is stopped.
Learn about Scala body parsers..
https://github.com/playframework/Play20/wiki/ScalaBodyParsers
Thanks,
While I was working on a project I had to save large content of data from text area filed in a form.
I'm using Play Framework 2.0.2 as a web framework and using scala html templates as views.
I have text area filed in my form to add html data (Actually here I'm using ace.js that is high quality code editor. Ill give brief introduction to ace later).
Ok Here I do not post form binding with model class but just think that there is a simple model class lets say Page. Most important thing is the saving part of this program. Here I have posted my save definition(function).
def save = Action(parse.urlFormEncoded(maxLength = 1024 * 1000))
{ implicit request =
//More code goes here.. I have not posted
Page.save(pageForm)
Redirect(Pages.show(
new ObjectId(page))).flashing("message" ->
"Page Saved !!!") } }) }
parse.urlFormEncoded(maxLength = 1024 * 1000)
It accepts 1000 KB of data. default length is 100 KB. I have to save 600KB of data (from text area) and without above code browser is hanging and data is not saved and ultimately browser is stopped.
Learn about Scala body parsers..
https://github.com/playframework/Play20/wiki/ScalaBodyParsers
Thanks,
Comments