No, all my statements relate to Struts2.1.1. The RestfulActionMapper in
Struts2.0.11 is an entirely different beast
Due to the dependency on CodeBehind and the major changes affecting that
plugin it can't be claimed to be ready for production use at this time.
There are still a few features missing from the Struts2.1.1 REST plugin
that are desirable - primarily handling of unsupported methods and http
codes. eg. if your action doesn't have a 'show' method the result
should be a 405 Error code (method not supported) instead of throwing an
exception. Some important changes will come through with the
Conventions plugin (eg. that index URLs call an index action). In
addition its currently primarily-focused on CRUD operations and I've
encountered some annoyances when trying to implement
transformation-style services. However it's still being actively
developed and the more people that us it the more like it'll improve.
I'm using it in a system NOT YET RELEASED for production and hopefully
I'll contribute some patches to the plugin as I proceed.
Roberto Nunnari wrote:
Thank you Jeromy.
I'll look into that and experiment a bit!
humm.. just one more question.. is it ready for production use?
From your statements I understand that you use them all for
production use, but if I look at the struts 2.0.11 distribution
there's no rest plugin and on the wiki I see that the rest
plugin is only available on 2.1.1..
Also, the struts 2.0.11 documentation for RestfulActionMapper
it reads: 'RESTful URLs are experimental.'
Can you confirm that you're successfully deploying RESTful
applications for production use using struts 2.0.11?
Best regards.
--
Robi
Jeromy Evans wrote:
Hi Roberto,
The CodeBehind plugin is probably being replaced with the
"Convention" plugin in Struts2.1.1 - a merge of SmartURLs, CodeBehind
and Zero-Configuration into one plugin. The purpose is that by
following some conventions almost all the configuration can be
eliminated. The intention is to make it easy to migrate from
CodeBehind.
In the case of Tiles2, yes, the plugin includes a @Result annotation
that can be included on each action class. The annotation is
equivalent to the result in struts.xml (sets the name, the type and
the parameters). In the Tiles2 result case you just need to state
that, for example, for result "index" the result is a tile . I was
thinking only last night it a "tiles naming convention" may
eventually be useful for me too. Of course, your html results,
whether JSP, FTL, VM, can also all use Tiles2 tags if you want to
minimize use of the @Result annotation (eg: use
tiles:insertDefinition within orders-index.jsp). I use both SiteMesh
and Tiles2 (together) with the Rest plugin to nice effect.
You'll find CodeBehind, SmartURLs and ZeroConfiguration information
on the Struts2 wiki.
regards,
Jeromy Evans
Roberto Nunnari wrote:
Hi Jeromy.
That's very cool!
One question comes to my mind.
As I have no idea what the CodeBehind plugin is, and as
I usully use the tiles plugin, is it possible/easy/hard
to use REST-CodeBehind-Tiles2 together?
Thanks!
--
Robi
Jeromy Evans wrote:
Hi Frans,
Were you able to checkout the trunk of Struts 2.1 and build it?
If you got that far, then you have a copy of the full rest
show-case in the apps directory. Yes, there are surprisingly few
settings as the showcase uses the CodeBehind plugin so there's no
struts.xml or other essential configuration files.
As a quick run-down of the how the application works:
- the rest plugin is included via the pom.xml. All the other
dependencies except junit are transitive. - web.xml enables the
struts filter and init-params specify where the actions can be
found (and enables dev mode)
- There's one action, OrdersController, a mock service
(OrdersService) and a business object (Order). The REST actions
are called Controllers following the RubyOnRails conventions.
- The default index.jsp file will simple redirect to GET /orders
- When you GET /orders/, the index () method is executed in the
OrdersController action. It loads the list of orders and returns
the "index" result. - CodeBehind maps the index result to
orders-index.jsp and the html result is rendered.
- If you GET /orders/1, the show() method is executed in the
OrdersController action. It loads the order with that id and
returns the "show" result. Again, the CodeBehind plugin maps this
to orders-show.jsp based on the convention.
- So on for post, new, delete, put etc operations - they call a
method and render a default result.
In addition:
- When you get /orders/1.json, the ContentTypeHandler will
serialise the model as JSON instead of executing a view result
- When you get /orders/1.xml, the ContentTypeHandler will
serialise the model as XML instead of executing a view result.
You can view both of these in the browser.
That's basically it. There's minimal configuration required because
it's a convention-based application.
I hope that helps. Build it and experiment!
regards,
Jeromy Evans
Frans Thamura wrote:
hi all
i just see the rest-showcase. this is amazing approach
but i only see the example class , and no setting about this
anyone can give me the glue about this ?
still lost about how the REST in struts 2.1.11, how does it wor?
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition. Version: 7.5.516 / Virus Database:
269.19.2/1224 - Release Date: 14/01/2008 5:39 PM
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]