I have a class with the following structure:
package controllers
import play.api.mvc._
class MyController extends Controller {
private var myVar = ""
def stepOne() = Action {
implicit request => {
myVar = request.queryString("var").mkString
Ok(views.html.stepOne())
}
}
def stepTwo() = Action {
implicit request => {
println(myVar)
Ok(views.html.stepTwo())
}
}
}
The idea is that I can call stepOne with some query parameters, they're saved in the class, then I can retrieve them in stepTwo. This class is only used in testing, to mock out certain functionality.
The problem is myVar
is not stored, when I print out myVar
in step two, it is still an empty string (I can print it out in step one and it's the correct, non-empty value). What is going on?