Hi,
My apologizes that my english is not well. I am a chinese, I have achieved
four projects by T3 since last Oct.
In our company, We have two teams. One team develop projects by stored
procedure + JSP, the other uses Hibernate + Spring + Tapestry. several weeks
ago, we decided to merge the technologies of two teams. So, I created a extra
function for T3, in order to implement the develop way of stored procedure +
tapestry.
The extra function is a webflow, like Spring Webflow. T4 is different with
T3 significantly and less documents , I feel at a loss what to do. Thank you
very much for any suggestion.
tapestry webflow:
I implement some classes and interface. The whole theme is that Tapestry is
undertaking the function similar to Spring MVC, Tapestry is only to render the
datas which come from webflow. The webflow transmits the data from stored
procedure to Tapestry, and the name of the jumped page comes from stored
procedure.
The webflow have double-duty xml files:
One is bean-xml file. There is only one bean-xml file in a project.
<?xml version="1.0" encoding="gb2312"?>
<beans>
<spring location="web/WEB-INF/classes/applicationContext.xml"/>
<bean id="fruitShop" class="com.tapestry.webflow.FlowInitFruitShop">
<property name="location" value="web/WEB-INF/classes/webflow-
fruitShop.xml"/>
</bean>
<bean id="actionBuy" class="com.tapestry.webflow.TransitionBuyFruit"/>
<bean id="actionAccount"
class="com.tapestry.webflow.TransitionAccount"/>
<bean id="actionFruitBuy"
class="com.tapestry.webflow.FlowInitFruitShop"/>
</beans>
The other is flow-xml file.every flow has its own flow-xml file. I consult
Spring webflow to define it.
<?xml version="1.0" encoding="gb2312"?>
<webflow start-state="buyFruit">
<view-state id="buyFruit" page="FirstPage">
<action on="buy" actionId="buy"/>
<action on="account" actionId="account"/>
<action on="checkOut" actionId="checkOut"/>
</view-state>
<action-state id="buy" bean="actionBuy">
<transition on="success" viewId="accountView"/>
<transition on="false" viewId="flowEnd"/>
</action-state>
<action-state id="account" bean="actionAccount">
<transition on="countAll" viewId="accountView"/>
</action-state>
<view-state id="accountView" page="SecondPage">
<action on="fruitBuy" actionId="fruitBuy"/>
<action on="checkOut" actionId="checkOut"/>
</view-state>
<action-state id="fruitBuy" bean="actionFruitBuy">
<transition on="fruitBuy" viewId="buyFruit"/>
</action-state>
<action-state id="checkOut" bean="actionAccount">
<transition on="flowEnd" viewId="flowEnd"/>
</action-state>
<end-state id="flowEnd" page="ThirdPage"/>
</webflow>
Via webflow, MVC structure is more obvious in fact. A responsible one of
Tapestry is view-state state, and action-state bears the responsibility for
Control. The combination of tapestry and webflow is :
First, in tapestry engine:
public class MyEngine extends BaseEngine {
public WebflowManagement getFlowManager() {
return (WebflowManagement) ((MyGlobal) getGlobal()).getFlowManager();
}
public void setFlowManager(WebflowManagement flowManager) {
((MyGlobal) getGlobal()).setFlowManager(flowManager);
}
protected void setupForRequest(RequestContext context) {
super.setupForRequest(context);
WebflowManagement flowManager = getFlowManager();
if (flowManager == null) {
flowManager = new WebflowManagement("web/WEB-
INF/classes/webflow-bean.xml");
setFlowManager(flowManager);
}
}
public void renderResponse(IRequestCycle cycle, ResponseOutputStream output)
throws ServletException, IOException {
Object[] object = cycle.getServiceParameters();
if (!error && object!=null && object.length>2 && object[1]!=null &&
object[1] instanceof String) {
String flowId_actionOn = (String)object[1];
if(flowId_actionOn.indexOf("_flowId=")==0 ||
flowId_actionOn.indexOf("_actionOn=")==0) {
FlowViewState flowViewState = null;
if(object[0]!=null && object[0] instanceof
FlowViewState) {
flowViewState = (FlowViewState)object[0];
}
Map valueMap = null;
if(object[2] instanceof Map) {
valueMap = (Map)object[2];
}
String serviceName = cycle.getService().getName
();
//tapestry corresponds to webflow
this.getFlowManager().activateWebFlow
(flowViewState, flowId_actionOn, valueMap);
//this object descripts <view-state> in flow-xml
flowViewState = this.getFlowManager
().getFlowViewState();
object[0] = this.getFlowManager
().getFlowViewState();
object[1] = null;
//the data which comes from stored
//procedure via webflow
object[2] = this.getFlowManager
().getFlowValueMap();
cycle.setServiceParameters(object);
//<view-state>'s attribute:page
cycle.activate(flowViewState.getPageName());
}
}
this.error = false;
super.renderResponse(cycle, output);
}
private boolean error = false;
protected String getStaleLinkPageName() {
error = true;
return STALE_LINK_PAGE;
}
protected String getStaleSessionPageName() {
error = true;
return STALE_SESSION_PAGE;
}
protected String getExceptionPageName() {
error = true;
return EXCEPTION_PAGE;
}
}
Second:
1)active webflow in DirectService:
public void submit(IRequestCycle cycle) {
Object[] object = new Object[]{null, "_flowId=fruitShop", null};
cycle.setServiceParameters(object);
}
2)active webflow in ExternalService:
<a href="#" jwcid="@ExternalLink" page="SecondPage" parameters='ognl:new
java.lang.Object[]{flowViewState, "_actionOn=account", null}'>帐目</a>
3)get data from webflow:
public void pageBeginRender(PageEvent event) {
Visit visit = (Visit)this.getVisit();
if (!event.getRequestCycle().isRewinding()) {
Object[] object = event.getRequestCycle().getServiceParameters
();
flowViewState = (FlowViewState) object[0];
Map valueMap = (Map) object[2];
this.setFruitList((List) valueMap.get("fruitList"));
visit.setBuyFruitList((List) valueMap.get("fruitList"));
}else {
//considering Form submit will active pageBeginRender()
this.setFruitList(visit.getBuyFruitList());
}
}
download demonstration :http://www.cdmcs.com/Mytapestry.rar
or http://gzdlw.blogchina.com/inc/MyTapestry.rar.doc(please modify
MyTapestry.rar.doc to MyTapestry.rar after download)
Please tell me how to replant my webflow to T4? I am a jackaroo, just 1- years
experience as full-time software developer. Thank you very much for any
suggestion about the transplant or webflow. If there is any confusion about my
depiction, I will tell more details.
ADong
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]