struts & tiles plugin & webflow
Hi guys,
I'm trying arround with webflow and want to integrate into an existing struts/tiles application. One issue I had was that the tiles plugin does not allow any requestprocessors which do not extend from TilesRequestProcessor (ASF bug 22828). That wasn't that hard to solve, I simply copied your bindingRequestProcessor and make it extend the tilesrequestprocessor. Not very nice and futureproof but it works for now.
Now I face another tiles exception and I don't have a clue how to recover from this:
Code:
314142 [P1-2] WARN xyz - /register.html:
javax.servlet.jsp.JspException: ServletException in '/WEB-INF/jsp/register_step1.jspf': The errors instance must be set on this action form in order to access form properties
at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:921)
at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:460)
at org.apache.jsp.WEB_002dINF.jsp.layouts.DefaultLayout_jsp._jspx_meth_tiles_insert_3(DefaultLayout_jsp.java:609)
at org.apache.jsp.WEB_002dINF.jsp.layouts.DefaultLayout_jsp._jspx_meth_html_html_0(DefaultLayout_jsp.java:305)
at org.apache.jsp.WEB_002dINF.jsp.layouts.DefaultLayout_jsp._jspService(DefaultLayout_jsp.java:116)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:427)
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:496)
at org.mortbay.jetty.servlet.Dispatcher.dispatch(Dispatcher.java:263)
at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:157)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:261)
at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:237)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:300)
at com.xyz.tst.webapp.struts.CustomBindingRequestProcessor.process(CustomBindingRequestProcessor.java:131)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:427)
at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:822)
at net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:300)
at net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:84)
at net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter.doFilter(SecurityEnforcementFilter.java:181)
at net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
at net.sf.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:372)
at net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
at net.sf.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:217)
at net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
at net.sf.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:179)
at net.sf.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:125)
at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:813)
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:494)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:569)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:624)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1434)
at org.mortbay.http.HttpServer.service(HttpServer.java:896)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:814)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:981)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:831)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:366)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
As there a lot of config files I'm not sure which one are relevant for you. Basically this happend after loading the first view. That means the following steps in the workflow were executed, and the first view in the wizard (step1) started to display (until the exception):
Code:
<action-state id="setupForm">
<action bean="registerFormAction"/>
<transition on="success" to="formView"/>
</action-state>
<!--
Display the input form view.
-->
<view-state id="formView" view="page.register.step1">
<transition on="submit" to="bindAndValidateForm"/>
</view-state>
My struts-config looks like:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<!-- ======================================== Form Bean Definitions -->
<form-beans>
<!-- A single action form adapter for your entire app is all you need, if you
wish to take advantage of Spring's POJO-based data binding and validation. -->
<form-bean name="actionForm" type="org.springframework.web.struts.BindingActionForm"/>
</form-beans>
<!-- =================================== Global Exception Definitions -->
<global-exceptions>
<exception key="error.required"
type="org.springframework.dao.DataAccessException"
path="page.error.dataAccessFailure" />
</global-exceptions>
<!-- =================================== Global Forward Definitions -->
<global-forwards></global-forwards>
<!-- =================================== Action Mapping Definitions -->
<action-mappings>
<!-- flow actions -->
<action path="/register"
type="org.springframework.web.flow.struts.FlowAction"
name="actionForm" scope="request"
className="org.springframework.web.flow.struts.FlowActionMapping">
<set-property property="flowId" value="registerFlow" />
</action>
</action-mappings>
<!-- A custom request processor is neccessary for deferred, POJO-based binding and validation
No more Action Form proliferation! :-) -->
<!-- controller processorClass="org.springframework.web.struts.BindingRequestProcessor"/ -->
<controller processorClass="com.example.app.webapp.struts.CustomBindingRequestProcessor"/>
<!-- ================================ Message Resources Definitions -->
<message-resources parameter="messages" />
<!-- ======================================= Plug Ins Configuration -->
<!-- plugin neccessary for making Commons BeanUtils aware of the BindingActionForm adapter -->
<plug-in className="org.springframework.web.struts.BindingPlugin"/>
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
</plug-in>
<!-- plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,
/WEB-INF/validation.xml" />
</plug-in -->
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml" />
<set-property property="definitions-debug" value="0" />
<set-property property="definitions-parser-details" value="1" />
<set-property property="definitions-parser-validate"
value="true" />
</plug-in>
</struts-config>
In my Action I set the POJO formobject as follows:
Code:
public RegisterFormAction() {
super();
// use you could also do this in the application context XML ofcourse
setFormObjectName("RegisterActionForm");
setFormObjectClass(RegisterFlowActionForm.class);
setValidator(new RegisterFormValidator());
}
public Event calculateAge(RequestContext context) throws Exception {
// pull the date from the model
RegisterFlowActionForm flowForm = (RegisterFlowActionForm)context.getRequestScope().get("RegisterActionForm");
// put it in the model for display by the view
//context.getRequestScope().setAttribute(AGE_NAME, ageStr);
return success();
}
As it is a little bit unclear to me how the object is mapped to the actionForm definition in the struts-config and the settings in the Action class I changed the name from "RegisterActionForm" to "actionForm" but this resulted into a
Code:
60467 [P1-9] ERROR org.apache.struts.taglib.tiles.InsertTag - ServletException in '/WEB-INF/jsp/register_step1.jspf': null
org.apache.jasper.JasperException
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
So, that's all I have. It's not simple to explain as I have yet started with the webflow. Can't you use my description?
Thanks,
Markus