playforscala / sample-applications Goto Github PK
View Code? Open in Web Editor NEWSample applications that go with the book Play for Scala
Sample applications that go with the book Play for Scala
Hi, I use play-slick for the chapter05 example( https://github.com/lshoo/products ), and when I define a product form mapping in controller like below:
// in controller
private val productForm = Form(
mapping(
"id" -> optional(longNumber),
"ean" -> longNumber.verifying(
"validation.ean.duplicate", Products.findByEan(_).isEmpty
),
"name" -> nonEmptyText,
"description" -> nonEmptyText
)(Product.apply)(Product.unapply)
)
when compile the project, report this:
[products] $ compile
[info] Compiling 1 Scala source to E:\play2-lshoo\playforscala-sample\chapter02
products\target\scala-2.10\classes...
[error] E:\play2-lshoo\playforscala-sample\chapter02\products\app\controllers\Pr
oductController.scala:25: could not find implicit value for parameter s: play.ap
i.db.slick.Config.driver.simple.Session
[error] "validation.ean.duplicate", Products.findByEan(_).isEmpty
[error] ^
[error] one error found
error Compilation failed
How to solve the problem? Thanks!
the configuration injection introduced at
ff9fb14
does not work; the result displayed (in the web-page) is.
import play.api.Configuration (implicit lang: Lang, configuration: Configuration) debug: user=configuration.getString("environment.user"), lang=lang.code, date=2016-08-25
changing to user=@configuration .. renders the error:
not found: value configuration
In /Users/xxxx/work/scala/play/book/sample-applications/ch02-your-first-play-application/first-sample/app/views/debug.scala.html:8
I have no idea how to solve this..
Hi,
Can you update the codes to be compliant of Play Framework 2.5.?
I am very frustrated especially about internationalization and external messages, which is chapter 2 of the book.
could not find implicit value for parameter messages:
Spent 2 days on this issue, I already followed all the documentations available on the Play Framework website
Thanks in advance.
If the user clicks on an EAN and changes it, the message 'Cannot parse parameter ean as Long' appears. Better to only apply contenteditable' to specific cells instead of entire rows. A little bit of clicking produced this displayed text in the middle column:
<td>Paperclip Giant PlainNo Tear Paper Clip <!DOCTYPE html> <html> <head> <title>Bad request</title> <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAlFJREFUeNqUU8tOFEEUPVVdNV3dPe8xYRBnjGhmBgKjKzCIiQvBoIaNbly5Z+PSv3Aj7DSiP2B0rwkLGVdGgxITSCRIJGSMEQWZR3eVt5sEFBgTb/dN1yvnnHtPNTPG4PqdHgCMXnPRSZrpSuH8vUJu4DE4rYHDGAZDX62BZttHqTiIayM3gGiXQsgYLEvATaqxU+dy1U13YXapXptpNHY8iwn8KyIAzm1KBdtRZWErpI5lEWTXp5Z/vHpZ3/wyKKwYGGOdAYwR0EZwoezTYApBEIObyELl/aE1/83cp40Pt5mxqCKrE4Ck+mVWKKcI5tA8BLEhRBKJLjez6a7MLq7XZtp+yyOawwCBtkiBVZDKzRk4NN7NQBMYPHiZDFhXY+p9ff7F961vVcnl4R5I2ykJ5XFN7Ab7Gc61VoipNBKF+PDyztu5lfrSLT/wIwCxq0CAGtXHZTzqR2jtwQiXONma6hHpj9sLT7YaPxfTXuZdBGA02Wi7FS48YiTfj+i2NhqtdhP5RC8mh2/Op7y0v6eAcWVLFT8D7kWX5S9mepp+C450MV6aWL1cGnvkxbwHtLW2B9AOkLeUd9KEDuh9fl/7CEj7YH5g+3r/lWfF9In7tPz6T4IIwBJOr1SJyIGQMZQbsh5P9uBq5VJtqHh2mo49pdw5WFoEwKWqWHacaWOjQXWGcifKo6vj5RGS6zykI587XeUIQDqJSmAp+lE4qt19W5P9o8+Lma5DcjsC8JiT607lMVkdqQ0Vyh3lHhmh52tfNy78ajXv0rgYzv8nfwswANuk+7sD/Q0aAAAAAElFTkSuQmCC"> <style> html, body, pre { margin: 0; padding: 0; font-family: Monaco, 'Lucida Console', monospace; background: #ECECEC; } h1 { margin: 0; background: #AD632A; padding: 20px 45px; color: #fff; text-shadow: 1px 1px 1px rgba(0,0,0,.3); border-bottom: 1px solid #9F5805; font-size: 28px; } p#detail { margin: 0; padding: 15px 45px; background: #F6A960; border-top: 4px solid #D29052; color: #733512; text-shadow: 1px 1px 1px rgba(255,255,255,.3); font-size: 14px; border-bottom: 1px solid #BA7F5B; } </style> </head> <body> <h1>Bad request</h1> <p id="detail"> For request 'PUT /products/asdf' [Cannot parse parameter ean as Long: For input string: "asdf"] </p> </body> </html>
Unfortunately, some of the applications fail to compile as they are still in Play 2.1. For example, in sample-applications/ch02-your-first-play-application/products-list/ app/controllers/Products.scala
, Ok(views.html.products.list(products))
gives and error stating that "products is not in views.html". An upgrade to Play 2.2 would be appreciated.
The chatroom project shows how a WS server can push to a client, but only shows how a client sends an HTTP request to the server, requiring a refresh. JavaScript clients can call websocket.send(message) any time. How can the Play app be configured so it accepts the send and silently processes it? For bonus points, is there a way for the Play app to send an acknowledgement to the JavaScript client, again without causing a screen refresh?
Mike
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.