playframework-2.0

How can I do a Twitter Reverse Auth In Scala Play Framework?

可紊 提交于 2019-12-22 18:27:26
问题 I'm writing a play application (in scala) and I'm trying to perform the reverse-auth step that is outlined by twitter here: https://dev.twitter.com/docs/ios/using-reverse-auth The step sounds like an ordinary RetrieveRequestToken to https://api.twitter.com/oauth/request_token with the additional parameter of setting the x_auth_mode=reverse_auth THe play framework makes use of Sign-Post (https://code.google.com/p/oauth-signpost/) and I was wondering how I can leverage the WS library and Sign

Models subpackages in Play framework

♀尐吖头ヾ 提交于 2019-12-22 15:37:47
问题 The list of classes in my models package is getting pretty big and I want to refactor some of the classes into their own subpackage. For instance, all forms go into models.forms , all users go into models.users , etc. However if I now declare a template that takes a form: @(myForm : Form[MyForm]) This gives me a not found: Type MyForm -error. I've tried importing the class: @import models.form.MyForm but this doesn't make any difference. 回答1: You need to fully-qualify MyForm in the first line

FakeApplication using a specific application.conf?

主宰稳场 提交于 2019-12-22 12:36:15
问题 How can I create a FakeApplication to run my tests using my dev.conf instead of the default application.conf ? My current test consists of the following construct: Map<String, String> map = new HashMap<>(); map.put("config.file", "/path/to/dev.conf"); FakeApplication fakeApplication = fakeApplication(map); TestServer testServer = testServer(3333, fakeApplication); // testServer.start(); running(testServer, HTMLUNIT, new F.Callback<TestBrowser>() { public void invoke(TestBrowser browser) { /

Java make a separate annotation that combines a others

孤人 提交于 2019-12-22 11:18:04
问题 Working with Play Framework 2.2, making a RESTfull API. In a model I'm using, I wanted to output(Json with Jackson) only the Id of a related object, not the entire object. I found how to do that, as follows: @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") @JsonIdentityReference(alwaysAsId = true) @JsonIgnore public Object myObject; The Json output will contain a JsonNode "myObjectId: 1". For instance. The IdentityInfo and IdentityReference take care

Call play2 template with variable arguments of type Html

空扰寡人 提交于 2019-12-22 10:33:53
问题 How can I call a template with a variable number of arguments that have Html type in play? I created a template in play2 defined like the following: @(tabs: Html*) <div class="btn-group" style="margin-bottom:20px"> @for((tab,index) <- tabs.zipWithIndex){ <a class="btn btn-mini btn-info active" id="display-hierarchy-@index" href="javascript:void(0)"><i class="icon icon-random icon-white"></i></a> } </div> @for((tab,index) <- tabs.zipWithIndex){ <div id="display-hierarchy-tab-@index" class=

Why Eclipse shows error with Play Framework render method?

回眸只為那壹抹淺笑 提交于 2019-12-22 09:26:15
问题 I am getting an error at return : public static Result home(String name) { return ok(home.render(name)); } For which Eclipse says, home can't be resolved . I know it is more of Scala than Java, but is there any way I can get rid of such errors. Well, without disabling error messaging (I see lot of such answers here on SO). Also, is there anyway I can make my Eclipse work autocomplete for Scala ? Ah, I just noticed one more problem there. To use an external jar, all I have too keep jars in a

Is there a way to generate Code from a DB in Java Play 2 Framework?

。_饼干妹妹 提交于 2019-12-22 09:19:29
问题 Does anyone know how to easily generate code from a database in Play Framework 2.0?? I know they have a module but it seems this is for version 1.X. Anyone? 回答1: The CRUD module is only for Play 1.2.x, it's not available in Play 2.0. It MAY be available in Play 2.1, but I'm not sure if that's still on the roadmap. 回答2: Your question has 2 aspects: Create all models, base on a database. There you can start with the jpa-generator for play 1.x, because ebean use JPA too. It should be nearly what

Play 2.0 “management” console commands

谁说我不能喝 提交于 2019-12-22 09:04:15
问题 I'd like to create some custom commands to manage my play 2.0 application (similar to Django's management commands), so I can run things like play import-data <data> . This seems to be something one would do by writing SBT commands (like Play's own), but specific to the particular project and with access to a project's resources (models etc.) Being fairly new to Scala, and new to both Play and SBT, I cannot get my head around how to do this, and particularly the dependency management that is

Can't create composite primary key with foreign key in PLAY 2.0

对着背影说爱祢 提交于 2019-12-22 08:55:13
问题 This is a situation I want to represent in my PLAY project: table clients { client_id (pk), description } table items { client_id (fk, pk), item_id (pk) } In the 'items' table I want to have a composite primary key that will consist of combined client_id and item_id. I have read JPA documentation as well as many posts on the topic but everything fails again and again. This is one of many versions I have tried - closest to the JPA documentation. @Entity @Table(name = "items") public class

POJO to JSON in Play framework

若如初见. 提交于 2019-12-22 07:18:23
问题 Trying to get Play 2.0 to return JSON from a POJO. But I recieve the error The method toJson(Writes<A>) in the type Json is not applicable for the arguments (Product) And my code is: public static Result index(String date) { Product item = new Product(); return ok(Json.toJson(item)); } Any ideas? 回答1: Make sure you import the right Json class using import play.libs.Json . You probably used play.api.libs.Json which is targeted for the Scala API, not the Java API. 来源: https://stackoverflow.com