2014-04-24 20:16 GMT+02:00 Antonio Sánchez <ads...@gmail.com>:
Hello.
1. Nowadays: Is RESTful the most recommended approach for implementing CRUD
applications with Struts2? Or is it equivalent to old CRUD style? What are
you doing in your new projects?
No, if your application is a simple CRUD I'd recommend to do it in
classic way, with REST you're building more an API than CRUD - and
designing API is hard :-)
2. Where can I find detailed documentation about RESTful with Struts2? IMHO,
current REST plugin documentation (1) lacks some deepness for newbies like
me.
That's all, maybe some book but I cannot recall which one. Can you
address what are you missing in REST plugin documentation
3. I don't understand the mechanism of returning HttpHeader instances in
action (controller) methods. How does it work?
With REST you must return a bit more than just a result name to use -
ie. status code, cache, etc, that's why HttpHeader is used instead -
just to be clear, even from ordinary Struts action you can return
result directly, eg. instead return "success" do return new
ServletRedirect(...)
4. Should actions always implement ModelDriven?
Nop, as far I remember no
5. Why not extending ActionSupport? Do I still have the full stack of
services ActoinSuport provides: validation, text access... ?
Yes you can, but as REST is just limited to returning simple data
(JSON) all the boilerplate of ActionSupport isn't needed. It's also
recommended way, to implement your own version (or even few) of
ActionSupport - basically it's just a set of simple interfaces, check
implementation.
6. Is convention plugin required? How to do REST without it?
No, but it's quite simpler.
7. Example application 'struts2-rest-showcase' is not working: 'HTTP 404 -
There is no Action mapped for namespace / and action name orders.'
cd apps/rest-showcase
mvn jetty:run
open http://localhost:8080
works!
8. Plug-in documentation error above mapping table: 'Error formatting macro:
snippet: java.lang.IllegalArgumentException: Invalid url: must begin with a
configured prefix.'
RESTful way looks to me as breaking the usual Struts2 style, that's why I
miss more explanatory documentation, specially if your say that indeed
RESTful is the good way of doing CRUD today.
I will try to fix that, anyway we are in process of moving all the
examples from Java source codes to Wiki (to solve problems like that)
Regards