I'm not sure if this isn't working as intended of it it's just me getting confused.
What I would like to do is to asynchronously delay an action, and await(int millis)
and I seem to be able to become friends.
Here's what happens:
1. Application.index
displays a form that sends a POST to Application.something
.
app/controllers/Application.java
public static void index() {
render();
}
app/views/Application/index.html
#{form @Application.something()}
<input type="submit">
#{/form}
2. Application.something
does its thing and then chains back to index
.
app/controllers/Application.java
public static void something() {
await(500);
// Here be business
index();
}
3. Play raises an application error: "The template Application/something.html does not exist".
So when render()
is called in Application.index
after execution in Application.something
has been suspended/resumed it tries to render the template of Application.something
, which of course doesn't exist.
If I remove await(500)
everything works just fine (the 302 is issued and index
is rendered as expected).
I can force a redirect with
redirect("/");
and get the result I want, but this feels ugly.
I can also set
request.action = "Application.index";
manually right after the await
and the render in Application.index
works (actually, the magic in Controller.template()
works) as intended.
So basically, is everything OK and I'm forced to live with using strings after await
rather than method calls, or is something a bit off?
Cheers, Tobias.