Casting String to Long in Scala in template play 2.0 template

playframework-2.0, scala, templates

Solution

Casting doesn't work like that in Scala.

You want:

session.get("user_id").toLong

Problem

How can I cast from a String to a long in a Scala play 2.0 template? I want to do the following where I have the action: `Application.profile(Long user_id)`: ``` <a href='@routes.Application.profile((Long) session.get("user_id"))'>@session.get("username")</a> ```

Original source