Search Results

Search found 68 results on 3 pages for 'playframework 1 x'.

Page 1/3 | 1 2 3  | Next Page >

  • Java PlayFramework & Python Django GAE

    - by Maik Klein
    I already know Java, C# and C++. Now I want to start with web development and I saw that some really big sites are built with Python/C++. I like the coding style of Python, it looks really clean, but some other things like no errors before runtime is really strange. However, I don't know what I should learn now. I started with Python but then I saw that Google App Engine also supports Java and the PlayFramework looks amazing too. Now I am really confused. Should I go with Python or Java? I found the IDE for Python "PyCharm" really amazing for web development. Does Java have something similar, eclipse maybe? I know that this question isn't constructive, but it will help me with my decision. What are pro and cons of both languages?

    Read the article

  • How to store date into Mysql database with play framework in scala?

    - by Rahul Kulhari
    I am working with play framework with scala and what am i doing : login page to login into web app sign up page to register into web app after login i want to store all databases values to user what i want to do: when user register for web app then i want to store user values into database with current time and date but my form is giving error. error: List(FormError(dates,error.required,List())),None) controllers/Application.scala object Application extends Controller { val ta:Form[Keyword] = Form( mapping( "id" -> ignored(NotAssigned:Pk[Long]), "word" -> nonEmptyText, "blog" -> nonEmptyText, "cat" -> nonEmptyText, "score"-> of[Long], "summaryId"-> nonEmptyText, "dates" -> date("yyyy-MM-dd HH:mm:ss") )(Keyword.apply)(Keyword.unapply) ) def index = Action { Ok(html.index(ta)); } def newTask= Action { implicit request => ta.bindFromRequest.fold( errors => {println(errors) BadRequest(html.index(errors))}, keywo => { Keyword.create(keywo) Ok(views.html.data(Keyword.all())) } ) } models/keyword.scala case class Keyword(id: Pk[Long],word: String,blog: String,cat: String,score: Long, summaryId: String,dates: Date ) object Keyword { val keyw = { get[Pk[Long]]("keyword.id") ~ get[String]("keyword.word")~ get[String]("keyword.blog")~ get[String]("keyword.cat")~ get[Long]("keyword.score") ~ get[String]("keyword.summaryId")~ get[Date]("keyword.dates") map { case id~blog~cat~word~score~summaryId~dates => Keyword(id,word,blog,cat,score, summaryId,dates) } } def all(): List[Keyword] = DB.withConnection { implicit c => SQL("select * from keyword").as(Keyword.keyw *) } def create(key: Keyword){DB.withConnection{implicit c=> SQL("insert into keyword values({word},{blog}, {cat}, {score},{summaryId},{dates})").on('word-> key.word,'blog->key.blog, 'cat -> key.cat, 'score-> key.score, 'summaryId -> key.summaryId, 'dates->new Date()).executeUpdate } } views/index.scala.html @(taskForm: Form[Keyword]) @import helper._ @main("Todo list") { @form(routes.Application.newTask) { @inputText(taskForm("word")) @inputText(taskForm("blog")) @inputText(taskForm("cat")) @inputText(taskForm("score")) @inputText(taskForm("summaryId")) <input type="submit"> <a href="">Go Back</a> } } please give me some idea to store date into mysql databse and date is not a field of form

    Read the article

  • How to download images in playframework jobs?

    - by MrROY
    I have a playframework Job class like this: public class ImageDownloader extends Job { private String[] urls; private String dir; public ImageDownloader(){} public ImageDownloader(String[] urls,String dir){ this.urls = urls; this.dir = dir; } @Override public void doJob() throws Exception { if(urls!=null && urls.length > 0){ for (int i = 0; i < urls.length; i++) { String url = urls[i]; //Dowloading } } } } Play(1.2.4) has lots of amazing tools to make things easy. So i wonder whether there's a way to make the downloading easy and beautiful in play ?

    Read the article

  • playframework auto-test Jenkins CI wait for completion?

    - by notbrain
    I am trying to set up Jenkins CI for a playframework.org application but am having trouble properly launching play after the auto-test command is run. The tests all run fine, but it seems as though my script is launching both play auto-test and play start --%ci at the same time. When the play start --%ci command runs, it gets a pid and everything, but it's not running. FILE: auto-test.sh, jenkins runs this with execute shell #!/bin/bash # pwd is jenkins workspace dir # change into approot dir cd customer-portal; # kill any previous play launches if [ -e "server.pid" ] then kill `cat server.pid`; rm -rf server.pid; fi # drop and re-create the DB mysql --user=USER --password=PASS --host=HOSTNAME < ../setupdb.sql # auto-test the most recent build /usr/local/lib/play/play auto-test; # this is inadequate for waiting for auto-test to complete? # how to wait for actual process completion? # sleep 60; wait; # Conditional start based on tests # Launch normal on pass, test on fail # if [ -e "./test-result/result.passed" ] then /usr/local/lib/play/play start --%ci; exit 0; else /usr/local/lib/play/play test; exit 1; fi

    Read the article

  • Third party multipart request in playframework

    - by Brian
    I'm making an application to post photos to yfrog and twitpic and I am having a little trouble figuring out how to set the parameters. Here is my code: public static Result index() { HttpClient httpclient = new DefaultHttpClient(); WSRequestHolder holder = WS.url("http://api.twitpic.com/2/upload.json"); holder.setHeader("Authorization", ""); return async(holder.post("").map(new Function<WS.Response, Result>() { public Result apply(WS.Response response) { return ok(response.getBody()); } })); } Now, I don't expect this to actually get an ok response from the server, as I am just testing the responses that I get back from the server, and that is one that says I need to provide the api key. I figured as much, but I'm not sure of the syntax for providing that parameter, as I need to also give the name of the file and the file. I tried setting holder.post("key=somekey"), with the hope that I would get a different error message (like the key you provided is invalid) but I just get the same error. I'm assuming that I probably need to send it in the for of a multipart request, but I am not very experienced with this kind of request and can't find any play documentation on how to create a multipart request, other than in an html form. Any suggestions and help will be much appreciated. And fyi, I do know that there are yfrog and twitpic java classes to handle this kind of stuff, but I want to do it myself, more so for learning how to do this kind of stuff. Thanks in advance!

    Read the article

  • Playframework sends 2 queries for fetched query

    - by MRu
    I currently have problems with the JPA at the play framework 1.2.4. I need to have a UserOptions model in a separate database and want to join it lazyly cause its only needed in one query. In this query I want to load the options eagerly and by searching I found out that can only be done by using a join query. If I use eager instead oder lazy, everything would be fine by using User.findById() and the options and the user is found in one query. But play sends two queries when I use a 'left join fetch' query. So heres the query: User.find(" SELECT user FROM User user LEFT JOIN FETCH user.options options WHERE user.id = ? ", Long.parseLong(id)).first(); And here the models: @Entity public class User extends Model { @OneToOne(mappedBy = "user", fetch = FetchType.LAZY) public UserOptions options; // ... } @Entity public class UserOptions extends Model { @OneToOne(fetch = FetchType.LAZY) public User user; } The question is why play sends two query for the fetch query? Thanks in advance

    Read the article

  • Strange Play Framework 2.2 exceptions after trying to add MySQL / slick

    - by Mike Cialowicz
    I'm working on a Play 2.2 application, and things have gone a bit south on me since I've tried adding my DB layer. Below are my build.sbt dependencies. As you can see I use mysql-connector-java and play-slick: libraryDependencies ++= Seq( jdbc, anorm, cache, "joda-time" % "joda-time" % "2.3", "mysql" % "mysql-connector-java" % "5.1.26", "com.typesafe.play" %% "play-slick" % "0.5.0.8", "com.aetrion.flickr" % "flickrapi" % "1.1" ) My application.conf has some similarly simple DB stuff in it: db.default.url="jdbc:mysql://localhost/myDb" db.default.driver="com.mysql.jdbc.Driver" db.default.user="root" db.default.pass="" This is what it looks like when my Play server starts: [info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000 (Server started, use Ctrl+D to stop and go back to the console...) [info] Compiling 1 Scala source to C:\bbq\cats\in\space [info] play - database [default] connected at jdbc:mysql://localhost/myDb [info] play - Application started (Dev) So, it appears that Play can connect to the MySQL DB just fine (I think). However, I get this exception when I make any request to my server: [error] p.nettyException - Exception caught in Netty java.lang.NoSuchMethodError: akka.actor.ActorSystem.dispatcher()Lscala/concurren t/ExecutionContext; at play.core.Invoker$.<init>(Invoker.scala:24) ~[play_2.10.jar:2.2.0] at play.core.Invoker$.<clinit>(Invoker.scala) ~[play_2.10.jar:2.2.0] at play.api.libs.concurrent.Execution$Implicits$.defaultContext$lzycompu te(Execution.scala:7) ~[play_2.10.jar:2.2.0] at play.api.libs.concurrent.Execution$Implicits$.defaultContext(Executio n.scala:6) ~[play_2.10.jar:2.2.0] at play.api.libs.concurrent.Execution$.<init>(Execution.scala:10) ~[play _2.10.jar:2.2.0] at play.api.libs.concurrent.Execution$.<clinit>(Execution.scala) ~[play_ 2.10.jar:2.2.0] The odd thing is that the 2nd request (to the exact same URL, same controller, no changes) comes back with a different error: [error] p.nettyException - Exception caught in Netty java.lang.NoClassDefFoundError: Could not initialize class play.api.libs.concurr ent.Execution$ at play.core.server.netty.PlayDefaultUpstreamHandler.handleAction$1(Play DefaultUpstreamHandler.scala:194) ~[play_2.10.jar:2.2.0] at play.core.server.netty.PlayDefaultUpstreamHandler.messageReceived(Pla yDefaultUpstreamHandler.scala:169) ~[play_2.10.jar:2.2.0] at com.typesafe.netty.http.pipelining.HttpPipeliningHandler.messageRecei ved(HttpPipeliningHandler.java:62) ~[netty-http-pipelining.jar:na] at org.jboss.netty.handler.codec.http.HttpContentDecoder.messageReceived (HttpContentDecoder.java:108) ~[netty-3.6.5.Final.jar:na] at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:29 6) ~[netty-3.6.5.Final.jar:na] at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessage Received(FrameDecoder.java:459) ~[netty-3.6.5.Final.jar:na] The URL / controller that I'm requesting just renders a static web page and doesn't do anything of any significance. It was working just fine before I started adding my DB layer. I'm rather stuck. Any help would be greatly appreciated, thanks. I'm using Scala 2.10.2, Play 2.2.0, and MySQL Server 5.6.14.0 (community edition).

    Read the article

  • Play framework 1.x on Tomcat - httpOnly cookies

    - by aishwarya
    I'm setting application.session.httpOnly=true in the application.conf and generating a war file and deploying on tomcat. I still see the cookie generated as HttpOnly=No and it is editable. This is an issue with play 1.x running on tomcat 6 (i.e. servlet api 2.x). Apparently, http only flag for cookies was only introduced in servlet 3.0 and so is only available in tomcat 7+ has anybody identified a workaround for this so far (so I could have http only cookies for play 1.x on tomcat 6.x ) ? the httpOnly flag on context in tomcat only works for tomcat's jsessionid cookie... also, can I run a play 1.x app on servlet 3.0 ? PS: This was also posted on the play framework's google groups but we did not receive a response and so posting on SO.

    Read the article

  • PlayDependencyClassLoader does not find application code

    - by jkschneider
    When a third party dependency attempts to load a class defined in a Play application using Class.forName(className, true, Thread.currentThread().getContextClassLoader()); Play will throw a ClassNotFoundException because the context class loader is of type PlayDependencyClassLoader which apparently only contains classes defined in jar dependencies. Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: eventstore.Commit at org.mapdb.SerializerPojo.classForName(SerializerPojo.java:96) at org.mapdb.SerializerPojo$1.deserialize(SerializerPojo.java:74) at org.mapdb.SerializerPojo$1.deserialize(SerializerPojo.java:39) This only occurs when Play is started with play run. Starting Play with play start loads the class correctly. It would be a shame to sacrifice the class hot-swapping because of this behavior. Is there a known workaround?

    Read the article

  • assigning to local variables in scala template in play framework

    - by user3548344
    I am trying to define the local variables and assign to them as below : @defining((Json.parse(value), ("GGGGGG"))) {case (json:JsValue, lb)=> @{lb=json\\"myTestField"} } but getting the error reassignment to val. So I tried to declare lb as var like @defining((Json.parse(value), ("GGGGGG"))) {case (json:JsValue, lb:var)=> @{lb=json\\"myTestField"} } but getting the error identifier expected but 'var' found How can I assign to variable lb?

    Read the article

  • Play framework does not return page and static content

    - by Anton
    I'm using play framework in production for one of my web projects. From time to time Play does not render main page or does not return some of the static content files. I have attached few screenshots below. First screenshot displays firebug console, loading of the site is stucked at the beginning, when serving home page. Second screenshot display fiddler console, when 2 static resources are not loading. This issue is hard to reproduce, it happens 1 of 15 time, I have to delete cache data and reload page. (pressing CRTL-F5 in FF). Issue can be reproduced in most of the browsers. Initially, I was thinging that there is something wrong with hosting provider. But I have changed hosting provided and issue has not gone. Version of the play is 1.2.2. Play is running as standalone server. Not sure, but probably deploying Play to Jetty/Tomcat/Resin would help. Also I'm thinging about rewriting application to another stack (well-known for me - j2ee, spring, whatever) I have no idea how to debug and resolve this issue. Any clue ? Has anyone faced same issue with Play before ?

    Read the article

  • How can I write a "user can only access own profile page" type of security check in Play Framework?

    - by karianneberg
    I have a Play framework application that has a model like this: A Company has one and only one User associated with it. I have URLs like http://www.example.com/companies/1234, http://www.example.com/companies/1234/departments, http://www.example.com/companies/1234/departments/employees and so on. The numbers are the company id's, not the user id's. I want that normal users (not admins) should only be able to access their own profile pages, not other people's profile pages. So a user associated with the company with id 1234 should not be able to access the URL http://www.example.com/companies/6789 I tried to accomplish this by overriding Secure.check() and comparing the request parameter "id" to the ID of the company associated with the logged in user. However, this obviously fails if the parameter is called anything else than "id". Does anyone know how this could be accomplished?

    Read the article

  • parse.json of authenticated play request

    - by niklassaers
    I've set up authentication in my application like this, always allow when a username is supplied and the API-key is 123: object Auth { def IsAuthenticated(block: => String => Request[AnyContent] => Result) = { Security.Authenticated(RetrieveUser, HandleUnauthorized) { user => Action { request => block(user)(request) } } } def RetrieveUser(request: RequestHeader) = { val auth = new String(base64Decode(request.headers.get("AUTHORIZATION").get.replaceFirst("Basic", ""))) val split = auth.split(":") val user = split(0) val pass = split(1) Option(user) } def HandleUnauthorized(request: RequestHeader) = { Results.Forbidden } def APIKey(apiKey: String)(f: => String => Request[AnyContent] => Result) = IsAuthenticated { user => request => if(apiKey == "123") f(user)(request) else Results.Forbidden } } I want then to define a method in my controller (testOut in this case) that uses the request as application/json only. Now, before I added authentication, I'd say "def testOut = Action(parse.json) {...}", but now that I'm using authentication, how can I add parse.json in to the mix and make this work? def testOut = Auth.APIKey("123") { username => implicit request => var props:Map[String, JsValue] = Map[String, JsValue]() request.body match { case JsObject(fields) => { props = fields.toMap } case _ => {} // Ok("received something else: " + request.body + '\n') } if(!props.contains("UUID")) props.+("UUID" -> UniqueIdGenerator.uuid) if (!props.contains("entity")) props.+("entity" -> "unset") props.+("username" -> username) Ok(props.toString) } As a bonus question, why is only UUID added to the props map, not entity and username? Sorry about the noob factor, I'm trying to learn Scala and Play at the same time. :-) Cheers Nik

    Read the article

  • Play! 1.2.5 with mongodb | Model Validation not happening

    - by TGV
    I have a simple User model whose fields are annotated with play validation annotations and morphia annotations like below. import play.data.validation.*; import play.modules.morphia.Model; import com.google.code.morphia.annotations.*; @Entity public class User extends Model{ @Id @Indexed(name="USERID", unique=true) public ObjectId userId; @Required public String userName; @Email @Indexed(name="USEREMAIL", unique=true) @Required public String userEmail; } Now I have a service which has a CreateNewUser method responsible for persisting the data. I have used Morphia plugin for the dao support. But the problem is that User Document gets persisted in mongo-db even if userName or userEmail is NULL. Also @Email validation does not happen // Below code is in app/controllers/Application.java User a = new User(); a.userName = "user1"; // calling bean to create user, userService is in app/service/UserService userService.createNewUser(a); It does not work even after adding @valid and validation.hasErrors() check.Below code is in app/service/UserService public void createNewUser(@Valid User user) { if (Validation.hasErrors()) { System.out.println("has errors"); } else { // TODO Auto-generated method stub userDao.save(user); } }

    Read the article

  • How to define default values optional fields in play framework forms?

    - by natalinobusa
    I am implementing a web api using the scala 2.0.2 play framework. I would like to extract and validate a number of get parameters. And for this I am using a play "form" which allows me to define optional fields. Problem: For those optional fields, I need to define a default value if the parameter is not passed. The code is intended to parse correctly these three use cases: /test?top=abc (error, abc is not an integer) /test?top=123 (valid, top is 123) /test (valid, top is 42 (default value)) I have come up with the following code: def test = Action { implicit request => case class CData(top:Int) val p = Form( mapping( "top" -> optional(number) )((top) => CData($top.getOrElse(42))) ((cdata:CData) => Some(Some(cdata.top))) ).bindFromRequest() Ok("all done.") } The code works, but it's definitely not elegant. There is a lot of boiler plate going on just to set up a default value for a missing request parameter. Can anyone suggest a cleaner and more coincise solution?

    Read the article

  • Adding Apache common dependency to Play Framework 2.0

    - by Mooh
    i want to import org.apache.commons.io but i'm getting this error: [info] Compiling 1 Java source to /home/ghost/Bureau/app/play-2.0.1/waf/target/scala-2.9.1/classes... [error] /home/ghost/Bureau/app/play-2.0.1/waf/app/controllers/Application.java:9: error: package org.apache.commons.io does not exist [error] import org.apache.commons.io.*; [error] ^ [error] /home/ghost/Bureau/app/play-2.0.1/waf/app/controllers/Application.java:41: error: cannot find symbol [error] FileUtils.copyFile(file, destinationFile); [error] ^ [error] symbol: variable FileUtils [error] location: class Application [error] 2 errors [error] {file:/home/ghost/Bureau/app/play-2.0.1/waf/}waf/compile:compile: javac returned nonzero exit code [error] application - Play can't find package org.apache.commons.io . How i can i add it as a dependency ?

    Read the article

  • play framework WS API always escape character ';' and '=' in URL

    - by user2512057
    When I send a URL like abc.efg.com/query?para1=cat;para2=dog, play WS API always convert it to abc.efg.com/query?para1=cat%03Bpara2%03Ddog. Of course, there are http:// in the beginning in the URL. my code is as below. val url= "http://abc.efg.com/query?para1=cat;para2=dog" val response = WS.url(url).get() When I use fidder or netmon to look at the data that sent to sever, I found play framework WS (2.1.5) always change to the URL above I mentioned. How do I tell WS not to convert?

    Read the article

  • Playframework and Django

    - by n002213f
    I have worked with Django before and have recently seen the Play framework. Is this the Java community's answer to Django? Any experiences with it? Any performance comparisons with other Java web frameworks? Edit:Almost similar to http://stackoverflow.com/questions/1597086/any-experience-with-play-java-web-development-framework, the responses, unfortunately don't say much about the framework.

    Read the article

  • PlayFramework with Scala and Morphia

    - by AKRamkumar
    I keep getting this exception: Oops: CannotCompileException An unexpected error occured caused by exception CannotCompileException: [source error] ds() not found in models.dc What is wrong with my code? Here is models.ds package models import com.google.code.morphia.annotations._ @Embedded class ds{ @Indexed var xs : Double=0 @Indexed var xc : Double=0 @Indexed var ys : Double=0 @Indexed var yc : Double=0 @Indexed var zs : Double=0 @Indexed var zc : Double=0 } Here is models.dc package models import com.google.code.morphia.annotations.{Embedded, Entity, Indexed} @Entity class dc{ @Indexed var name : String = null @Embedded var summary : ds = new ds() }

    Read the article

  • Using design-patterns to transform web-service model classes into local model classes and vise versa

    - by Daniil Petrov
    There is a web-application built with play framework 1.2.7. It contains less than 10 model classes. The main purpose of the application is a lightweight access to a complex remote application (more than 50 model classes). The remote application has its own SOAP API and we use it for synchronization of data. There is a scheduled job in the web-app which makes requests to the remote app. It gets bunches of objects from the remote model and populates corresponding objects of the local model. Currently, there are two groups of classes - the local model and the remote model (generated from wsdl schema). It is not allowed to make any modifications to the remote model. Transformations are being made in the scheduled job class. When it gets objects from the remote app it creates local objects. Recently, it was decided to add a possibility to modify the remote objects. It requires more transformations on our side. We need to transform from remote to local model when reading objects and from local to remote when changing objects. I wonder if this would be possible to use some design-patterns to reduce a number of transformations?

    Read the article

  • Web Frameworks caring about persistence?

    - by Mik378
    I have noticed that Play! Framework encompasses persistence strategy (like JPA etc...) Why would a web framework care about persistence ?! Indeed, this would be the job of the server-sides components (like EJB etc...), wouldn't this? Otherwise, client would be too coupled with server's business logic. UPDATE: One answer would be : it's more likely used for simple application including itself the whole business logics. However, for large applications with well-designed layers(services, domain, DAO's etc..), persistence is not recommended within web client layer since there would be several different web(or not) clients.

    Read the article

  • Is Play Framework good for doing some logic parallely?

    - by pmichna
    I'm going to build a web application that's going to host urban games. A user visits my website, clicks "Start game" and starts receiving some SMS messages when gets to some location and has to answer them to get points. My question: is Play suitable for this kind of application? From what I've read I know for sure it's ok for traditional web applications: user interface for same data storage and manipulation. But what if after clicking the "start button" some logic has to go on its own course? How would I handle parallely checking geolocation of the players (I have API for that)? I guess in some threads that would ping them every ~5 sec. and do some processing but is it possible to just "disconnect" them from the main user interface? So to sum up: I want an application written in Play that starts a separate thread for a game after clicking "start game" and other users are able to view their data (statisctics etc.), while the threads work their way with the game logic. I found something like jobs but they are documented for version 1.2 (current one is 2.2). Sorry for my somewhat fuzzy explenation, I tried to do my best.

    Read the article

  • Play 2 with Scala or Java?

    - by Mik378
    I want to develop a big personal project using Play 2 Framework. I am expert with Java language but it seems, with the few articles I read that Play 2 works perfectly and especially with Scala. I've never worked with Scala but I already learned concept as closures, functional programming etc... Learning it would be interesting. I am really motivated for but I wonder if there are some people who have started coding with Play2/Java and have changed for Play2/Scala that could explain their major concrete advantages.

    Read the article

  • How can I install the Play! framework using typesafe-stack? [migrated]

    - by lhk
    I'd like to create a new project with the Play! framework. My system is Mint 12 64bit. Since the newest version of Play! is already bundled with the typesafe-stack, I thought installation would be easy. I added the typesafe repo, then I apt-get updated and apt-get installed typesafe-stack with the command g8 typesafehub/play-scala. I successfully created a new project in my home folder. Now the problems begin: I don't know how to access Play! with this installation. After creating the project, I tried to convert it into an Eclipse project, it but there's no play command available in the terminal. How can I get a "standard" Play! installation on Linux? What happens to the tools bundled in the typesafe stack - Where do they go?

    Read the article

  • How to generate complex url like stackoverflow?

    - by Freewind
    I'm using playframework, and I hope to generate complex urls like stackoverflow. For example, I want to generate a question's url: http://aaa.com/questions/123456/How-to-generator-a-complex-url Note the last part, it's the title of the question. But I don't know how to do it. UPDATED In the playframework, we can define routes in conf/routes file, and what I do is: GET /questions/{<\d+>id} Questions.show In this way, when we call @{Questions.show(id)} in views, it will generate: http://aaa.com/questions/123456 But how to let the generated has a title part, is difficult.

    Read the article

1 2 3  | Next Page >