playframework

Sending multi part form data in post method in play/scala

ぃ、小莉子 提交于 2020-01-02 08:55:09
问题 How can I send multi part form data in post method in play scala using : scalaVersion:2.11.7 playVersion-2.1.5 回答1: You need to do a little code, then you can use it like val data = MultipartFormData(formFields, "asdasboundarystringas") WS.url(myUrl).post(data.body) The code of MultipartFormData you can find on the github: https://gist.github.com/EECOLOR/7649144 UPDATE Another method, I have been try it with Play 2.4.3 package controllers import play.api.Play.current import play.api.libs.ws._

Auto-reloading with Play framework on a network filesystem

£可爱£侵袭症+ 提交于 2020-01-02 07:21:08
问题 I'm running a Play framework application on a VirtualBox VM with the project source code in a directory shared from the host system. The auto-reload functionality of the framework doesn't work. This is (probably) caused by JNotify being unable to detect the changes to the source files, as the filesystem is not local. Both NFS and vboxsf suffer from the same issue. Is there any way around this? Play framework has a built-in fallback mechanism for detecting changes on systems where JNotify is

Play Framework 2.4 Ebean Id Generation

99封情书 提交于 2020-01-02 06:57:22
问题 until now we have been using Play 2.3.9 and we are now migrating to Play 2.4.1 When I use the old version of Play saving an Entity works but with the new verion the Id is not generated. I setup a new project from scratch and tried it to realize it works and the auto generated database has an Id field that auto increments while the old project has a database that uses sequences. I have been trying to configure play/ebean to use sequences but have not been succesfull thus far. I took a look

PlayFramework Testing: Uploading File in Fake Request Errors

ⅰ亾dé卋堺 提交于 2020-01-02 05:50:09
问题 I want to test my method, which requires uploading a file. It is initialized like this: val tempFile = TemporaryFile(new java.io.File("/home/ophelia/Desktop/students")) val part = FilePart[TemporaryFile]( key = "students", filename = "students", contentType = Some("text/plain"), ref = tempFile) val files = Seq[FilePart[TemporaryFile]](part) val formData = MultipartFormData( dataParts = Map(), files = Seq(part), badParts = Seq(), missingFileParts = Seq()) I pass it into the FakeRequest: val

Multiple upload file with PlayFramework

一个人想着一个人 提交于 2020-01-02 05:46:07
问题 I'm trying to upload multiple files at once with Play Framework, but I always get the first image for each uploaded. Here's a concrete case : The HTML : <form method="post" action="/upload" enctype="multipart/form-data"> <input type="file" name="image" /> <input type="file" name="image" /> <input type="file" name="image" /> <input type="file" name="image" /> <input type="submit" name="submit" value="Send images" /> </form> The controller : public static void upload() { File[] images = params

Json Writes in Play 2.1.1

爱⌒轻易说出口 提交于 2020-01-02 05:33:18
问题 I started using the Playframework recently and am implementing a site using Play 2.1.1 and Slick 1.0.0. I'm now trying to wrap my head around Json Writes as I want to return Json in one of my controllers. I've been looking at several references on the subject (like this one and this one but can't figure out what I'm doing wrong. I have a model looking like this: case class AreaZipcode( id: Int, zipcode: String, area: String, city: String ) object AreaZipcodes extends Table[AreaZipcode]("wijk

Ebean: Cascade with OneToOne – tries inserts instead of update

眉间皱痕 提交于 2020-01-02 05:29:08
问题 I'm using Scala with Ebean, and I've run into some serious trouble. The situation is quite simple, I have a parent entity: @Entity case class Person(@(PrivateOwned@field) @(OneToOne@field)(fetch = FetchType.LAZY, cascade = Array(CascadeType.ALL), orphanRemoval = true) @(JoinColumn@field)(name = "website_setting_id") websiteSetting: WebsiteSetting, @(Id@field)id: Long = 0) extends Model where WebsiteSetting is: @Entity case class WebsiteSetting(@(Column@field)(unique = true) domain: String,

play! framework ENUM and Groovy problem

自古美人都是妖i 提交于 2020-01-02 05:19:24
问题 I have something like the following- Woman.java ... @Entity public class Woman extends Model { public static enum Outcome { ALIVE, DEAD, STILL_BIRTH, LIVE_BIRTH, REGISTER } ... } File.java ... @Entity public class Form extends Model { ... public Outcome autoCreateEvent; ... } Create.html #{select "autoCreateEvent", items:models.Woman.Outcome.values(), id:'autoCreateEvent' /} It saves ENUM value in DB, which is OK. But, when I reload/edit then the problem rises. Because it uses ALIVE, DEAD,

pagination in playframework

江枫思渺然 提交于 2020-01-02 04:04:21
问题 I want to implement pagination in Play FrameWork , Is there any tutorial or example for this I have explore there website and went through the tutorial but not able to implement pagination Thanks 回答1: I have implemented many pages in play! using the Play pagination module. It's working fine with no issues. I'll give you an idea of what I did, below. First I declare the ValuePaginator that points to a result set (in my case a MYSQL query) ValuePaginator vpaginator=query.resultList(); Then

Configuration Variables in Play! Framework

故事扮演 提交于 2020-01-02 03:57:05
问题 I am new to Play!, and wrote my first application. This app has a set of URL's it depends of, to pull data from and also to return valid URLs on the XML responses. This app needs to run in different environments (Dev, Staging and Prod), and each environment will require its own set of URLs. I guess the place to define this set of URLs is in the application.conf file. However I don't seem to find out how, and later access them through the normal classes. As a related point, I don't want to use