Reputation: 477
I need to pass both a flash value and a session value into one view in Play Framework. Is this possible?
Upvotes: 1
Views: 732
Reputation: 1
@()(implicit flash : Flash, request: RequestHeader)
And then you can use it like this:
@if(request.session.get("example").toList(0) == example2){
<a href="#example>"><h5>example</h5></a>
}
Upvotes: 0
Reputation: 14401
Both the session and the flash objects are accessible from the request. Simply pass request from a controller to a view. Usually it's done by an implicit parameter:
@()(implicit request: RequestHeader)
@request.session.get("yourSessionKey")
@request.flash.get("yourFlashKey")
Upvotes: 3