Reputation: 31
I have such error in scala template:
not found: value flash
19 @if(flash.contains("bladLogowania")) {
20 <p class="error">
21 @flash.get("bladLogowania")
22 </p>}
I have read that there is some change but I am not sure how make this work. I still want check this values from template directly. Any ideas?
Upvotes: 2
Views: 1241
Reputation: 1582
Changes I made to compile after 2.3 migration where using implicit flash becomes an issue:
To my Controller class:
add import play.api.mvc.RequestHeader;
change flash("success", "Logged Out");
to request.flash("success", "Logged Out");
To my scala.html classes using the implicit flash:
add (implicit request: play.api.mvc.RequestHeader)
change
@if(flash.contains("success")) {
<p class="success">
@flash.get("success")
</p>
}
to
@if(request.flash.data.contains("success")) {
<p class="success">
@request.flash.get("success")
</p>
}
Note the need to access the map using flash.data. Hope it helps!
Upvotes: 1
Reputation: 1
I face the same kind of errors when code for Play 2.3.X. I found that documentation about migration to 2.3.X is wrong. Digging the Play api doc I found that you just have to add a import to Http.context.Implicit to acess flash scope like you did before play 2.3.X:
@import play.mvc.Http.Context.Implicit
Upvotes: 0
Reputation: 23254
Change your controller code to request.flash instead of just flash
Upvotes: 2
Reputation: 3842
Please read the migration guide to 2.3: http://www.playframework.com/documentation/2.3.x/Migration23, specifically the "Session and Flash implicits" section
So your code would change to:
@if(request2flash.contains("bladLogowania")) {
<p class="error">
@request2flash.get("bladLogowania")
</p>
}
Upvotes: 0