You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@forrest.apache.org by Thorsten Scherler <th...@apache.org> on 2007/04/03 19:19:54 UTC
[RT] POJO contracts via spring
Hi all,
I am posting this to not forget about the idea, but release issues have
higher priority.
Lately I am using again spring and struts 2 in my projects and the bean
configuration of spring seems a perfect fit for contracts. It should be
very easy to use POJO contracts in the dispatcher.
The structurer definition for such contracts could look like:
<forrest:contract name="pojo-contract" class="tutorial.MyPojoContract"/>
or
<forrest:contract name="pojo-contract" bean="tutorial.MyPojoContract"/>
Since we now have a java object and not as usual a xsl contract we would
need to transform the java object back to xml. We could force each
contract to return xml but IMO it would better to use jx for transform
the POJO into markup.
So the flow would look like:
structurer contains pojo contract call ->
Class or spring-bean will be called (properties system can be used for
passing parameters as usual). POJO contracts does it job (e.g.
contacting db for a list of users) and fills the model (e.g.
model.setList(dao.getUsers());). ->
Then it will be passed to the jx-view (where we can use our model) and
compiled. ->
The returning result will be added to the structurer as usual and
processing will be proceed.
All the above described is MVC and one can imaging wrapper classes for
struts1 or struts2 (this does not even need a wrapper class) actions.
Using spring beans would further bring the benefit that one can use
already configured contracts in the structurer, reducing the properties
used in the contract.
Resume
------
structurer:
<forrest:contract name="pojo-contract" bean="tutorial.MyPojoContract"/>
contract (action + view):
MyPojoContract.java (action that fills the model)
myPojoContract.jx (view that presents the model)
wdyt?
salu2
--
Thorsten Scherler thorsten.at.apache.org
Open Source Java consulting, training and solutions
Re: [RT] POJO contracts via spring
Posted by Ross Gardler <rg...@apache.org>.
Thorsten Scherler wrote:
> I am posting this to not forget about the idea, but release issues have
> higher priority.
So, only a two sentence response.
> Lately I am using again spring and struts 2 in my projects and the bean
> configuration of spring seems a perfect fit for contracts. It should be
> very easy to use POJO contracts in the dispatcher.
...
> wdyt?
My Forrest2 experiment is already a Spring app, Cocoon 2.2 is also
spring based. So assuming one of these two routes is the way we go for
the next version of Forrest it is a no-brainer for me that every
component of Forrest should build on Spring.
Ross