开发者

Problem with flash scope - play framework

My problem is about putting and getting variables into/from the play scope.

It's not that it doesn't work at all, but it sometimes does and other times it doesn't, which is really odd. For example, the first time I run a selenium test which checks this problem, a exception is thrown, that the param can't be found in flash. The second, third, and fourth time everything works fine, which is very strange.

I also tried to solve it with session.put and session.get, but this doesn't work either, it has the same effect as flash.

Do you guys have any idea what I am开发者_如何学C doing wrong?

Kind regards


It is possible that you are setting the value into the flash scope at the wrong point, if it is only on the first attempt it is not working. Let me explain a little of how the flash scope works.

In an action on your server side, you can put something into Flash scope. This writes these values into a cookie (so you have a limit here of 4Kb). This cookie lives until the next request, and then is cleared out. So, Flash means it lives for this, and the next request only. Any thing else that needs to live longer needs to be stored in a DB or the Session cookie (I have purposely left out a cache here, as using caching for storing state without backing up with a DB breaks the stateless nature of Play).


The answer is, that the Selenium Tester (better said: the Test mode, startet with "play test") of Play! does clear the flash every two seconds, or so. It sounds very odd, but I tested it in detail. When I ran a test really quick, the thing worked. But while running it slowly, the flash scope got cleared at some time and it the programm failed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜