playframework-1.x

Why is this URL not opened from Play! Framework 1.2.4?

不羁岁月 提交于 2019-12-11 02:41:27
问题 I have a URL in my Play! app that routes to either HTML or XLSX depending on the extension that is passed in the URL, with a routes line like :- # Calls GET /calls.{format} Call.index so calls.html renders the page, calls.xlsx downloads an Excel file (using Play Excel module). All works fine from the browser, a cURL request, etc. I now want to be able to create an email and have the Excel attached to it, but I cannot pull the attachment. Here's the basic version of what I tried first :-

How can I sort a list in Play Framework templates?

混江龙づ霸主 提交于 2019-12-10 23:54:46
问题 I have this template rendering JSON content: [ #{list data} { "title": ${_.title}, "id": ${_.id} } #{if !_isLast},#{/if}#{/list} ] Is there a way to sort data inside the template before printing the data members? 回答1: It is possible: //src %{ exampleList = ["z", "y", "a", "b"] }% <ul> #{list items:exampleList.sort(), as:'product'} <li>${product}</li> #{/list} </ul> //rendered <ul> <li>a</li> <li>b</li> <li>y</li> <li>z</li> </ul> In addition you can give sort() a lambda expression how to sort

How to get a DateTime input in a Play! CRUD form?

夙愿已清 提交于 2019-12-10 17:19:40
问题 By default a java.util.Date field is represented in a CRUD form as a simple "DATE" input. public class DatedModel extends Model { public Date creationDate; in the CRUD admin I see: creationDate [TEXTINPUT] yyyy-MM-dd format. Is there any way to have a DateTime input instead, on selected fields only (not all of them modifying the application.conf date.format )? Is there a way to affect which "widget" is used for a given field in the 'automated' CRUD admin? 回答1: Something like this in your

Toggle Login/Logout based on if user is already logged in

断了今生、忘了曾经 提交于 2019-12-10 11:41:32
问题 I have a Play! web application. If the user is logged in, I would like to show a "Logout" link in the top menu. If the user is not logged in, I'd like to hide the "Logout" link and show a "Login" link instead. Easy, right? However, I am unable to find information on how to actually do this. So, how would I go about this? I used the yabe web app as an example. Is there a #{secure.check} equivalent to check if the user has already logged in? What's the easiest way? Help would be greatly

How to test email logic with Play Framework

五迷三道 提交于 2019-12-08 19:32:29
问题 I got an class that extends Mailer and would like to have automatic tests for that. With mock mailer I can get the mail to console but how to test mail logic from the automated test? (Is there something like Mailer testing with Rails?) br, Touko 回答1: While writing this question, I found this link : Testing mail sending by using Mock Mailer. So, one can access mails mailed with Mock mailer with play.libs.Mail.Mock as follows: String email = Mail.Mock.getLastMessageReceivedBy("joe@example.com")

How do I update a certain field of a Model in Playframework?

一世执手 提交于 2019-12-08 12:46:25
问题 Suppose we have a User class, if I want to update it's name: User user = User.findById(123); user.name = "someone"; user.save(); The generated SQL would be update user as user0 set user0.name = ? user0.email = ? ..... That means Play didn't realize I just want to update a single field. Is there any way could make the generated SQL only update the specified fields ? 回答1: Info: this is answer for Play 2 + Ebean! so it DOES NOT work with Play 1 + JPA There are some options in Ebean's API, so you

How to get iterator's index in Play's template?

╄→гoц情女王★ 提交于 2019-12-08 12:22:33
问题 I want to use a counter in a loop, so each table's row has its unique id attribute which indicates the current loop iteration. How can I access the current index? (in sample code marked as ITERATOR_HERE ) <table id="table_id" class="display"> <thead> <th>Key</th> <th>Value</th> <th></th> </thead> <tbody> #{list items:paras, as:'elem' } <tr> <td id="ITERATOR_HERE">${elem.sendAllKey}</td> <td>${elem.sendAllValue}</td> <td>button</td> </tr> #{/list} </tbody> </table> 回答1: The list tag creates a

Session/context lost in Play async/await

假装没事ソ 提交于 2019-12-08 08:17:50
问题 It seems the await() method loses context: public static action() { session.put("key", "value"); await(someAsyncCall()); // Now, for some reason the session doesn't have "key" } Is this a known issue? Any workarounds? 回答1: That is unfortunate. Since session is a thread local variable it does not get passed between new threads (which happens in your example). What is misleading and surprising, is that when the code resumes after the await method there is a session variable (but it is a

Linode 512 and play! framework

旧时模样 提交于 2019-12-08 05:17:06
问题 I'm a noob and I'm looking for some help on how to run my play framework on Linode 512. I'm using a debian image.My question is if I can just install java and then play! framework and just run it like that or do I need any front-end server to act like a proxy. Sorry for the noobish question. Thanks 回答1: Play framework is a complete stack. You can run it without any front end server acting as a proxy. However, if you also want to have SSL (although Play has SSL support, it is recommended to

Linode 512 and play! framework

眉间皱痕 提交于 2019-12-07 22:46:28
I'm a noob and I'm looking for some help on how to run my play framework on Linode 512. I'm using a debian image.My question is if I can just install java and then play! framework and just run it like that or do I need any front-end server to act like a proxy. Sorry for the noobish question. Thanks Play framework is a complete stack. You can run it without any front end server acting as a proxy. However, if you also want to have SSL (although Play has SSL support, it is recommended to use a complete HTTP server to handle this), or you want to run multiple Play applications that appear on the