playframework-2.1

Overriding Play 2.1 Checkbox Form Helper for Twitter Bootstrap

冷暖自知 提交于 2019-12-07 16:58:01
问题 I want to show an HTML checkbox followed by the label to the right. I followed Pere Villega's suggestion, and modified the Play 2.1-SNAPSHOT version of views.helper.checkbox.scala as views.helper.twitterCheckbox.scala . My project uses the version of Twitter Bootstrap provided by Webjars: @** * Generate an HTML input checkbox for Twitter Bootstrap. * * Example: * {{{ * @checkbox(field = myForm("done")) * }}} * * @param field The form field. * @param args Set of extra HTML attributes ('''id'''

Is the Twitter bootstrap helper in the Play framework deprecated?

一个人想着一个人 提交于 2019-12-07 06:59:02
问题 I often use the Twitter bootstrap form template helper in my web application as this is very easy. Yesterday I want to create a form with horizontal fields and found on GitHub a Pull-Request with a comment (one year old) from guillaumebort that the helper will be deprecated in the next version.But I found nothing about it in the Play Template helper Documentation. Is the helper already deprecated or will it get updated? Is there already any more sophisticated Bootstrap Template helper as

How to use multiple main.js files for RequireJs in Play Framework 2.1.1 Java?

旧城冷巷雨未停 提交于 2019-12-07 05:55:34
问题 I'm building a single-page app using, AngularJs + RequireJs in Play Framework 2.1.1. I have two application sitting inside the same Play server, admin dashboard and normal website. That's why I have two main.js files for Admin Dashboard and Normal website. The application structure looks like this. I got this from public/javascripts We want to separate the two pages that's why we have two main.js files. However, the problem I'm facing right now is that in the root main.js everything is fine.

Testing controller with fake session

為{幸葍}努か 提交于 2019-12-07 03:54:00
问题 I want to write test for my controller: Result changeAction = callAction(controllers.routes.ref.Users.changePassword()); assertThat(status(changeAction)).isEqualTo(OK); I have a http status code - 300. That's right it is redirect because I have a class named Secured package controllers; import play.mvc.*; import play.mvc.Http.*; public class Secured extends Security.Authenticator { @Override public String getUsername(Context ctx) { return ctx.session().get("userId"); } @Override public Result

Play Framework 2.1 Remove a core dependency

妖精的绣舞 提交于 2019-12-06 14:21:49
since a few day now i'm trying to use Joda-time 1.6.2 on a play project. I know the play framework already come with the Joda-time 2.1 and it should be compatible with 1.6.2 according to joda-time site. I'm trying to write an application that ask the user for a LocalDateTime and save the class with the attributes on a MongoDB using morphia. I'm facing a problem, i have to use a class that are currently using joda-time 1.6.2 and i cannot change it dependency neither update it to 2.1. Since i have no use for the joda-Time 2.1, is it possible some how remove this dependency from Play Framework 2

far future Expires header for static contents

寵の児 提交于 2019-12-06 13:39:06
问题 how wrote here http://developer.yahoo.com/performance/rules.html For static components: implement "Never expire" policy by setting far future Expires header i can gain performace avoiding http requests with a response as "304". In official play! documentation i can see how set cache-controll directives, but how i can set far future Expires header? best regards Nicola edit: thanks for the replay now it work as well! here there are the classes: conf/routes # Static files GET /assets/stylesheets

Change language of text in template in play framework 2.1.1

ぐ巨炮叔叔 提交于 2019-12-06 13:01:44
I want the user of the application can change the language in my play2 (play 2.1.1, scala 2.10.1) web application. I use @Messages.get(...) in my templates for i18n. I have application.langs="en,ru" in application.conf. I pass "en" or "ru" to that method: def index = Action { Ok(views.html.index()) } def changeLanguage(lang:String) = Action { implicit request => Logger.logger.debug("Change user lang to : " + lang) val referrer = request.headers.get(REFERER).getOrElse(HOME_URL) Redirect(referrer).withLang(Lang(lang)) } routes: GET / controllers.Application.index GET /index controllers

Update the Task model - RuntimeException: DataSource user is null?

时光怂恿深爱的人放手 提交于 2019-12-06 11:18:46
I started learning Play framework today and it is very good and easy to learn. I successfully completed the sample provided on their website , but I wanted to make some modifications to it. I wanted to see if could update the label of a particular task, so I followed the following approach First I added a route to update the data POST /tasks/:id/update controllers.Application.updateTask(id: Long) Then I added the following code to index.scala.html file @form(routes.Application.updateTask(task.id)) { <label class="contactLabel">Update note here:</label> @inputText(taskForm("label")) <br /> }

Play2 and Anorm, how do I make the One in a One to Many relationship aware of it's Manys

扶醉桌前 提交于 2019-12-06 06:21:32
I have a one to many relationship between User and LinkedAccount, a User can have several linked accounts. I have no problem in loading a LinkedAccount and it's User by doing: LinkedAccount(id, provider_user_id, salt, provider_id, auth_method, avatar_url, User.findBy(user)) in the parser. What I can't figure out is how load a user with it's LinkedAccounts. I guess I need to make the user aware of the LinkedAccounts.. but how? I would like to this to get rid of one extra sql call to the db everytime I want to find if the user have a linked account of the given type. Currently I do like this:

Dynamic Javascript using Scala template

亡梦爱人 提交于 2019-12-06 05:13:31
I am trying to localize my Javascript files. For instance, I would have: var count = 0; $('#choices .choice').each(function(i) { $('input', this).each(function() { count++ $(this).attr('placeholder', '@Message("placeholder.choice") ' + count) }) }) This would obviously work if the Javascript file is inside the Scala HTML template but I would prefer to have it in a dedicated file. To begin with, I am wondering if it is a good idea: what about caching file if it's content may change? In this case, there is a single parameter: having it in the URL would solve this problem? Eg: /assets/javascripts