playframework-2.0

playframework scala Seq[Future[Model]] removing the Future

醉酒当歌 提交于 2019-12-25 08:58:19
问题 I have the following issue, I have a Seq[Future[ProcessStepTemplatesModel]] and I want to remove the inner Future. What I excpected to get is a Seq[ProcessStepTemplatesModel] . The complete code looks like this Future.sequence { processSteps.map { step => // This is a "for each" over a Seq[ProcessStepTemplatesModel] val prerequisiteFuture = processStepPrerequisitesDTO.getProcessStepPrerequisiteProcessTemplateIds(step.id.get) prerequisiteFuture.map(prereqTemplates => { processTemplateDTO

Setting up Parent-Child Actor in Play Framework

佐手、 提交于 2019-12-25 08:18:06
问题 I just started working on Play Framework + Akka. I have one Parent Actor and one child Actor(in future it can exceed). I am making an Api call from a controller and expecting a response from child actor. NotificationController: @Singleton public class NotificationController extends Controller{ final ActorRef commActor; @Inject public NotificationController(ActorSystem system) { commActor = system.actorOf(CommActor.props, "comm-actor"); } public CompletionStage<Result> communicate(int isDirect

Scala Play Future Interdependancy

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 07:15:54
问题 I am using play-slick for my scala Play! dummy rest API. So, I have to fetch records from multiple tables. But, they are interdependent, i.e. Table_1 Table_2 id1 id2 id2 To fetch a record from Table_2 I have to fetch a record from Table_1 and then using id2 fetch from Table_2. My controller: def getEntity(id : Long) = Action.async { table1DAO.findById(id) map { t1 => t1 map { t1Entity => table2DAO.findById(t1Entity.id2) map { t2 => t2 map { t2Entity => Ok(Json.toJson(CombiningClass(t1Entity,

Play 2.5 - Run a Java method at certain times of day (cron)

余生长醉 提交于 2019-12-25 06:56:10
问题 I'm working on a Play 2.5 app that needs to run a method at midday, 2pm, 4pm every day autonomously. So far I have followed another answer on here which has got me most of the way. The application.conf file has been updated to look at the Module file, which binds to the OnStartup() method correctly. I believe the issue is to do with the code in the OnStartup() method, I've included the code below - is this the correct way to get something to run at certain times of day? package controllers;

JDBC Connection from play app

╄→尐↘猪︶ㄣ 提交于 2019-12-25 06:32:58
问题 I'm trying to establish a connection to an oracle database from an app written with play framework 2.0.4 and getting an SQLException (No suitable driver found for jdbc:oracle:thin:@....) when opening an connection. I'm using code that works fine standealone and the connection string in the exception is ok too (even tested it in 'Execute Query' and it worked). Play can even find my driver, because i have this statement at the beginning of my code which would throw a NoClassDefFound exception

Play! upload images and make them available in production at /assets/images

淺唱寂寞╮ 提交于 2019-12-25 06:27:52
问题 From the docs: When you package your application, all assets for the application, including all sub projects, are aggregated into a single jar, in target/my-first-app-1.0.0-assets.jar. This jar is included in the distribution so that your Play application can serve them. This jar can also be used to deploy the assets to a CDN or reverse proxy. I got a few image uploads in my application, everything works fine in development but in production it gives me errors. The thing is, I need those

Sticky Cookies in Scala

心不动则不痛 提交于 2019-12-25 03:42:42
问题 I've set a cookie in Scala similar to the following: val cookies:Seq[Cookie] = new Seq() val nDaysExpire:Int = 2000 val nSecondsExpire:Int = nDaysExpire * 24 * 60 * 60 val cookie:Cookie = new Cookie(sCookieID, sValue, Option(nSecondsExpire)) cookies = cookies:+ cookie Ok(views.html.main(sID)).withCookies(cookies:_*) and then I immediately delete the cookie in JavaScript. I have even deleted the cookie 30 seconds after the page has loaded. When I reload the page, the Scala code still sees the

Play framework - pass multiple images in a post request

↘锁芯ラ 提交于 2019-12-25 02:58:08
问题 WHAT I DID: I am developing Rest web services using POST method in the play framework(Using Java). I did create simple web service POST API and also called it from the client side. WHAT I WANT: In this I want to pass multiple images as parameters in the request to the service from the client side(android/IOS/web). But I didn't get any APIs/Tutorials regarding this. I did try to pass one image to the service. But when I pass the Image request, I am getting the null in the line "FilePart file =

Play framework - pass multiple images in a post request

陌路散爱 提交于 2019-12-25 02:58:04
问题 WHAT I DID: I am developing Rest web services using POST method in the play framework(Using Java). I did create simple web service POST API and also called it from the client side. WHAT I WANT: In this I want to pass multiple images as parameters in the request to the service from the client side(android/IOS/web). But I didn't get any APIs/Tutorials regarding this. I did try to pass one image to the service. But when I pass the Image request, I am getting the null in the line "FilePart file =

Play framework Json output issue

醉酒当歌 提交于 2019-12-25 02:55:48
问题 I have a simple action which outputs a json object string, like this: Ok(toJson(Map( "results" -> result_lists ))) This works all right. But if I do: Ok(toJson(Map( "action" -> action_string, // a Scala String "results" -> result_lists // a Scala List ))) I got No Json serializer found for type scala.collection.immutable.Map[String,java.io.Serializable] compilation error...what's the problem? 回答1: As others have posted in the comments before, the type of the Map is not something which can be