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]