playframework-2.0

Combining Play! Framework 2.xx with Angular.js

喜欢而已 提交于 2019-12-20 08:29:09
问题 I am having trouble is this marriage of 2 seemingly powerful frameworks. It seems most things that can be done by 1 can be done by 2.How to best utilize the two? Are there any patterns of thinking? Take a basic example of a CRUD application -- I can write a route mysite/listnames which maps to a controller in play! and this renders a template with the code -- @(names:List[String]) @main("Welcome") { @for( name <- names ){ <p> Hello, @name </p> } Note that main is a typical bootstrapping

Latex directives in template are causing `error in unicode escape`

回眸只為那壹抹淺笑 提交于 2019-12-20 06:17:42
问题 I want to include some LaTEX code in play framework 2.0 template, namely: \usepackage[T1]{fontenc} \usepackage[latin9]{inputenc} \usepackage{babel} Of course play complains with error in unicode escape error message because of \us... parts. How should I escape those pieces of text, so play compiles the template and I get verbatim LaTeX code in result? Tried my luck with @Html(), but it doesn't work either... 回答1: Create an method ie in Application.java controller: public static String latex

What are the i18n message ids for field infos and errors?

江枫思渺然 提交于 2019-12-20 05:15:31
问题 I'd like to translate the default constraints and error messages for markup generated by the views.html.helpers._ inputs. I couldn't find it in the documentation, and have already started browsing the code, but if anyone is faster than me please answer and be awarded. Here is the sample template code: @inputText(regForm("Login"), 'id-> "username", 'placeholder -> "Login", 'required -> "yes", 'autofocus -> "yes") And here is the generated HTML: <div id="username_field" class="error clearfix">

Database transactions in Play framework scala applications (anorm)

匆匆过客 提交于 2019-12-20 03:48:14
问题 I am developing an application using Play framework and scala. I am using anorm for data-access layer. And I've got a problem I could not solve. Brief: I want to be able to have methods in data-access objects (dao) to work inside transactions as well as being called alone. Details: I have data-access layer consist of class with methods that only executes particular SQL over database. Traditionally they looks like: def list() = DB.withConnection { implicit cn => ... } Now I want to have some

Play 2.2.1 Java: Whats the equivalent of @before filters from play 1.X?

一个人想着一个人 提交于 2019-12-20 02:51:35
问题 I want to implement a setUserIfPresent () method that puts a user object into the context like Http.Context.current().args.put("user", user); This method should be applied before every controller method so that views have access implicit access to the user. With Play1 I create a BaseController that invokes this method before all requests (@Before filter) and extended all other controllers from this one. How to achieve something like this in play2 using Java API? Seems like there is something

DB Plugin is not registered in Play 2.0

冷暖自知 提交于 2019-12-19 14:57:08
问题 I just started working with play, and I modified the way I'm doing a SQL read and I'm now getting the following error: [Exception: DB plugin is not registered.] The code I have for this class is: package models import play.api.db._ import play.api.Play.current import anorm._ case class Housing(id: Long, rent: String, address: String, street0: String, street1: String, neighbourhood: String) object Housing { def all(): List[Housing] = DB.withConnection { implicit c => SQL("select * from housing

Microservice Configuration in play 2 framework

早过忘川 提交于 2019-12-19 12:04:07
问题 I have divided my application into different projects in PLay 2. But I just realised I do not know how to run multiple play application in the same server. Anyone knows how to do it? Let us suppose it is not possible,Therefore, I will just deploy multiple play application in the same root project (The microservice will act as a plugin). Do you think this will defeat microservice architecture?. I will make each module act independently. 回答1: By server, I'm guessing you mean Tomcat / Jetty /

Testing scala Play (2.2.1) controllers with CSRF protection

旧城冷巷雨未停 提交于 2019-12-19 08:58:57
问题 I've been having some problems testing controllers that use Play's CSRF protection. To demonstrate this, I've created a very simple Play application that minimally exhibits the problem. https://github.com/adamnfish/csrftest The full details are on the README of that repository, but to summarise here: Consider a controller that is designed to handle a form submission. It has a GET method that uses CSRFAddToken and a POST method that uses CSRFCheck. The former adds a CSRF Token to the request

Constraints message in validator of play20

丶灬走出姿态 提交于 2019-12-19 08:52:02
问题 I would like to have a different message for a Constraints validator but i am wandering how to do.... example @Constraints.Required @Constraints.Pattern("\\d{1,6}") public String thisIsAnInt; I would like something @Constraints.Required @Constraints.Pattern(message="ThisismyspecificMessage",value=\\d{1,6}") public String thisIsAnInt; For showing it properly using the bootstrap in a form. It is possible? thanks a lot 回答1: As you wrote, you can use @Constraints.Required(message = "This is field

sbt: dynamic aggregation of subproject

给你一囗甜甜゛ 提交于 2019-12-19 05:54:20
问题 I would like to invent a system to dynamically discover subprojects and aggregate them into my project automatically. Or at least configure this somehow. To do this, I'm planning to have either a "modules" folder or an optional configuration file containing paths to the modules. In any case I'd need to loop through subfolders (or loop through a list of paths from a configuration file), and aggregate each subproject . I don't know how to do that. Currently I'm building in the Play framework