playframework-2.4

Play/Scala injecting controller into test

…衆ロ難τιáo~ 提交于 2019-12-07 05:16:53
问题 So according to Play 2.4 documentation (https://playframework.com/documentation/2.4.x/ScalaTestingWithScalaTest#Unit-Testing-Controllers), the controller should be set up as a trait like this trait ExampleController { this: Controller => def index() = Action { Ok("ok") } } object ExampleController extends Controller with ExampleController in order for a test to work like this class ExampleControllerSpec extends PlaySpec with Results { class TestController() extends Controller with

twitterBootstrap is not recognized in play framework 2.4?

烈酒焚心 提交于 2019-12-06 14:57:13
I'm using Play framework 2.4. I tried to use bootstrap as guided at https://www.playframework.com/documentation/2.0/ScalaFormHelpers . In my template, I used the import statement: @import helper.twitterBootstrap._ But I got a compilation error: object twitterBootstrap is not a member of package views.html.helper Am I missing something? Maybe it has beed removed as mentioned here: https://www.playframework.com/documentation/2.3.3/Migration23 The in-built Twitter Bootstrap field constructor has been deprecated, and will be removed in a future version of Play. There are a few reasons for this,

Play 2.4.x how use Messages and not MessagesApi I18N

本小妞迷上赌 提交于 2019-12-06 11:54:00
I've done a little bit different form the internationalization guide, at the play I18N guide I forced the result to the language in the query string, it works, but it needs to be done in the "correct way". It's a good form to keep the work and look for better approach later: NOTE: I USED THE "MessagesApi" to make it happen. please see the code below: package controllers import play.api._ import play.api.mvc._ import play.api.i18n.I18nSupport import play.api.i18n.Messages.Implicits._ import play.api.i18n.MessagesApi import javax.inject.Inject import play.api.i18n.Lang import play.api.i18n._

Play Framework 2 Language Code in URL Concept?

血红的双手。 提交于 2019-12-06 05:51:18
The manual about i18n is short: https://www.playframework.com/documentation/2.4.x/ScalaI18N Is there anything more that explains the concept for handling the user's language choice? What I'd like to achieve is what so many other sites do: put the language code into the URL http://namepedia.org/en/home/ http://namepedia.org/de/home/ ... And then, when calling (Java) Lang.defaultLang().language() or from a Scala template @lang.language I'd like to get that value. Of course with the usual resolving, it must be in the application.conf play.i18n.langs = [ "en","de" ] Do I really need to read it

How can I override Play's default Ebean server configuration?

女生的网名这么多〃 提交于 2019-12-06 00:42:12
问题 I don't want to define the default database configuration in the application.conf file. Instead, I want to construct the default EbeanServer programmatically and inject it myself into the DAO. The problem I am having is, if I create a guice binding for a EbeanServer provider and not define any configuration in the application.conf file, play errors out saying it cannot find a default configuration. Here's the code I have: public class EbeanServerProvider implements Provider<EbeanServer> {

Slick 3: how to drop and take on collections with some relations

对着背影说爱祢 提交于 2019-12-05 18:37:48
I'm working with Play! Scala 2.4 and Slick 3. I have a many to many relations as following: class Artists(tag: Tag) extends Table[Artist](tag, "artists") { def id = column[Long]("artistid", O.PrimaryKey, O.AutoInc) def name = column[String]("name") def * = (id.?, name) <> ((Artist.apply _).tupled, Artist.unapply) } The relation table: class ArtistsGenres(tag: Tag) extends Table[ArtistGenreRelation](tag, "artistsgenres") { def artistId = column[Long]("artistid") def genreId = column[Int]("genreid") def * = (artistId, genreId) <> ((ArtistGenreRelation.apply _).tupled, ArtistGenreRelation.unapply

Play 2.4 value routesImport is not a member of object play.Play.autoImport.PlayKeys

跟風遠走 提交于 2019-12-05 14:23:53
I am getting this error after migrating to 2.4 from 2.3. What is the right import statement I should use? error: value routesImport is not a member of object play.Play.autoImport.PlayKeys PlayKeys.routesImport += "se.radley.plugin.salat.Binders._", I have these import statements: import sbt._ import Keys._ import play.Play.autoImport._ import PlayKeys._ import WebKeys._ Should be like this: import play.sbt.routes.RoutesKeys ... RoutesKeys.routesImport += "se.radley.plugin.salat.Binders._" 来源: https://stackoverflow.com/questions/33900153/play-2-4-value-routesimport-is-not-a-member-of-object

Play Framework 2.4 and IntelliJ Idea

拥有回忆 提交于 2019-12-05 12:05:21
问题 I am trying to open a play 2.4 project in IntelliJ but since things have changed I don't know how to do this. In previous versions I could just run activator idea Or use the activator UI and click on generate intelliJ project, but in 2.4 the idea command doesn't seem to exist [error] Not a valid command: idea (similar: eval, alias) [error] Not a valid project ID: idea [error] Expected ':' (if selecting a configuration) [error] Not a valid key: idea (similar: clean) [error] idea [error] ^ And

in play 2.4 logback configurations, where is ${application.home} defined?

浪尽此生 提交于 2019-12-05 07:27:09
The link here shows you how to configure your custom logger. https://www.playframework.com/documentation/2.4.x/SettingsLogger I was just wondering where is the ${applicaation.home} defined, as it seems to not have been defined in my production environment. As indicated by @user316607, Play should define application.home by itself in the Logger.configure method . If you are seeing the value application.home_IS_UNDEFINED instead, and you're using compile-time dependency injection , you'll need to call Logger.configure yourself in your ApplicationLoader as explained in this blog post : class

How to do database initialization when using DI in Play 2.4?

主宰稳场 提交于 2019-12-05 06:31:27
问题 Play 2.4 discourages using GlobalSettings.onStart and whole Global object. I'm using play-slick and it has great DI sample in GitHub, but it is missing a example how to do database initialization. How does one implement the database initialization when using DI and when GlobalSettings.onStart is not available? Common cases for database initialization is: If in DEV mode, add these rows, if PROD do these. Examples wanted. 回答1: The trick is to place the initialisation in the constructor of the