forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <thors...@apache.org>
Subject [RT] POJO contracts via spring
Date Tue, 03 Apr 2007 17:19:54 GMT
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


Mime
View raw message