Introducing the Play Framework eBook

Posted: December 31, 2010 in Play Framework

A few days ago I released the Beta version of my new book “Introducing the Play Framework”.
To read more about the eBook, and to purchase, just visit the link

Happy New Year and happy reading!

  1. asd says:

    Great Job! thanks

  2. Sumit says:

    Just bought your book. Was wondering if you had a link to the soft copy of the code that is in the book.

    • codemwnci says:

      Not for the eBook, as the code can simply be copied and pasted.

      I will make the code available when the book becomes available in print (date to be confirmed).

  3. Riyad Kalla says:

    Just bought your book as well; hope it helps out with distribution. Appreciate you taking the time to write this up for us Play! developers.

  4. Al says:


    How long is the book?

    Might you post a table of contents?

    Does it cover using scala with play?



    • codemwnci says:

      The book is just over 200 pages A4, which is approximately around 300 pages of a normal sized book.
      If you click buy now on the page, there is a Preview link on the site where the book is hosted, which will give you the full contents table.

      The book is aimed at Java usage for Play. Scala is not covered.

  5. Evan says:


    Great book!

    I’m working through the ePlay app and just noticed a small errata: On page 84, the route “GET /listing/show” should be something like this:

    “GET /listing/show/{id}”

    • codemwnci says:

      The route in the book, and the one you have suggested are both valid routes. The difference is that the one you have specified actually conforms better to RESTful principles and also hides id variable from the URL, which is a little neater. The two routes will show the following

      GET /listing/show would route to /listing/show?id=123
      GET /listing/show/{id} would route to /listing/show/123

      So, both would work, but your way is neater. Thanks for the spot!

  6. Tns public says:

    Easy to read and understand, but I can not find code example to find average value from data in table. How to do it in Play!

    Thank you

    • codemwnci says:

      To achieve an average value from data in a table, you need to use a JPQL. I have achieve this in one of my apps in the following way. I have created a private method in one of my model objects, that allows me to average any field on my model.

      private Number getAverageScore(String fieldName) {
      return (Number) JPA.em().createNativeQuery("SELECT AVG("+fieldName+") FROM mytable").getSingleResult();

  7. Tns public says:

    Thank you very much cidewnci.

    Another question, I want to plot graph from data in table. Is there graph module to do this. I find only graph module for Facebook.

  8. Vortilion says:

    Hm, it destroyed my comment and deletesd the middle part of it… Guess because of the code.

    Again: it hast to be

    if page * 20 < results.count

    instead of

    if page * 20 >>”-Link on the last result page as well. For example if I have 40 db-entrys it will show 3 pages,

    1-20, 21-40 and 41-40.

  9. Vortilion says:

    On page 89 the word “public” has to be in lower case.

  10. Vortilion says:

    Found more errors:

    Chapter 3, page 80, 3.3.1: Attribute “buyNowEnabled” should be “boolean” as primitive type, NOT “Boolean” as wrapper class.

    Chapter 5, page 133, 5.2.3: In the p-element for the buyNowEnabled-Checkbox, DO NOT use the value-attribute (with flash item.buyNowEnabled). It won’t save the field to the database anymore. Just keep it like “input type=”checkbox” name=”item.buyNowEnabled”. If you want to keep the checkbox in case of a form-error, you have to build something like

    input type=”checkbox” name=”item.buyNowEnabled” #{flash[item.buyNowEnabled]?:checked=”checked”}

  11. Vortilion says:

    On page 138 & 139 in the Yaml-File you use 2010 as a year, should be 2020 (as you say it in the text after the Yaml-File).

  12. Vortilion says:


    3 of the 5 Tests in fail! “testSearchPlural()”, “testSearchSingle()” and “testShow()”.

    I’ve added a screenshot:

    • Vortilion says:

      Found the error: You have to add the line “%test.db=mem” to the application.conf! It also did overwrite my entire mysql-database with the data fron the yaml-File. -.-

  13. Vortilion says:

    On page, 148, the lines

    // we didn’t select a buy now price, so check it doesn’t display
    verifyTextNotPresent(‘Buy Now Price’)

    don’t make any sense here because it will never be displayed in the search-view if we saved a buyNowPrice… It only displays the title and the endDate!

  14. Vortilion says:

    Found an error in the search function, through testing. With your code it always shows ended auctions. The error is in the Query (

    Instead of

    long count = count(“title like ? OR description like ? AND endDate > ?”, likeSearch, likeSearch, new Date());
    List items =
    find(“title like ? OR description like ? AND endDate > ? order by endDate ASC”, likeSearch, likeSearch, new Date()).fetch(page, 20);

    it has to be

    long count = count(“(title like ? OR description like ?) AND endDate > ?”, likeSearch, likeSearch, new Date());
    List items =
    find(“(title like ? OR description like ?) AND endDate > ? order by endDate ASC”, likeSearch, likeSearch, new Date()).fetch(page, 20);

    The error was the missing braces around

    title like ? OR description like ?

    , AND does bind stronger than OR, so the statement return either ended auctions with a matching description OR any auction with matching title.

    • Vortilion says:

      Another error with the search after changing to the SearchResults-method:

      In the search-view it says

      #{if results}


      Problem is: “results” is always true. Why? The search method in always creates an SearchResults-Object, even if there are no search results. In that case it contains the values

      items = empty ArrayList with size = 0,
      count = 0.

      So in the view you have to write

      #{if results.count > 0}


  15. Vortilion says:

    Two Typos on page 203:

    3rd last paragraph:
    “[…] we display ${item.topBid}”
    It’s “${item.currentTopBid}”

    “[…] from the method getTopBid()”
    It’s “getCurrentTopBid()”

  16. Vortilion says:

    Pages 203, 204:

    You can also write the AJAX-Post in a shorter version:

    type: “POST”,
    url: ‘@{Application.addBid(, item.nextBidPrice)}’

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s