playframework / playframework/play1
Action chaining doesn't redirect when using non-static methods
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.6k
- Forks
- 671
- Avg merge
- 12d 15h
- Merged PRs (30d)
- 1
Description
Play Framework v1.4.2 added support for non-static controller methods (https://play.lighthouseapp.com/projects/57987/tickets/1934).
If we have two public non-static methods, and the first method calls the other, this does not trigger a redirect to the client. Instead, the second method is invoked directly by the first.
public class Application extends Controller {
public void first() {
second(); // Should do a redirect to second(), but doesn't
}
public void second() {
render(); // Should render Application/second.html, but doesn't
}
}
As a side-effect, Play tries to render a template corresponding to the first method instead of the second one, since we get the error message: The template Application/first.html does not exist.
A work-around is to explicitly do a redirect with redirect("Application.second");
However, Play developers are used to the redirect-behavior when one controller-method calls another
(See Action chaining) They may think that they can just remove the static keyword when upgrading to v1.4.2 or higher, but in fact they can't since this is not completely backwards-compatible.
Note that the same thing happens if the first method is non-static and the second is static.
Environment used: Play 1.4.4 and Java 1.8
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the action-chaining example with Play 1.4.4 and Java 8, using the non-static first() and second() controller methods described in the issue. Trace how the first method invokes the second and verify that chaining redirects to Application.second and renders Application/second.html rather than Application/first.html.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100