Coming from frameworks like Django and RoR I am used to show and handle forms from one action. (posting back to the action that shows the form) Is this possible in Struts2 as well? I’d like the following behavior:
1) “users/xyz/edit” gets called
2) HTTP GET -> showing the form
3) HTTP POST -> form validation -> saving data and redirect or return to the form
All the examples I have looked at work with two actions which I dislike.
Is there any solution or do I have to accept the Struts2 way of doing it?
Yes you can use the same Action class. Though its not as elegant as both those frameworks you mentioned since they encapsulate the REST principle at a framework level. Using the base Struts 2 framework, just add an actionType hidden parameter to your page and form, update it according to next expected action (display->validate->save->display).
Or alternatively you can use the REST plugin for Struts 2:
http://struts.apache.org/2.x/docs/rest-plugin.html
Hope that helps.