Hi
I'm about to begin looking at integrating SWF into struts 1.1.
Does anyone have any experience doing this? Are there any articles or tutorials which show how this is achieved?
Thanks
Jim
Hi
I'm about to begin looking at integrating SWF into struts 1.1.
Does anyone have any experience doing this? Are there any articles or tutorials which show how this is achieved?
Thanks
Jim
Take a look a the 'BirthDate' sample application, which illustrates Struts integration. Also take a look at the JavaDoc of the FlowAction class.
Erwin
I have downloaded the spring web flow pr4 and built the birthdate example and deployed it.
However when I click on the Birth Date anchor, I get the following stack trace:
Any ideas why this wouldn't just work out of the box?type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:75)
root cause
java.lang.NoSuchMethodError: org.apache.struts.action.ActionForward.<init>(Lorg/apache/struts/action/ActionForwardV
org.springframework.webflow.struts.FlowAction.toAc tionForward(FlowAction.java:180)
org.springframework.webflow.struts.FlowAction.exec ute(FlowAction.java:129)
org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:484)
org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1482)
org.apache.struts.action.ActionServlet.doGet(Actio nServlet.java:507)
javax.servlet.http.HttpServlet.service(HttpServlet .java:697)
javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:75)
Jim
What version of Struts are you using?
We tested birthdate on 1.2.7.
Keith
Keith Donald
Core Spring Development Team
1.1
Will SWF work with 1.1?
Jim
The problem is that ActionForward copy constructor is just a 1.2.1 thing.
We really need somethign like that so we can set the redirect property:
Maybe there is a 1.1 compatible solution...?Code:private ActionForward toActionForward(ViewDescriptor viewDescriptor, ActionMapping mapping, HttpServletRequest request) { if (viewDescriptor != null) { WebUtils.exposeRequestAttributes(request, viewDescriptor.getModel()); ActionForward forward = mapping.findForward(viewDescriptor.getViewName()); if (forward != null) { forward = new ActionForward(forward); } else { forward = new ActionForward(viewDescriptor.getViewName()); } forward.setRedirect(viewDescriptor.isRedirect()); forward.freeze(); return forward; } else { return null; } }
Keith
Keith Donald
Core Spring Development Team
Okay, I committed the following fix:
See PR5 tommorrow, test now please :-)Code:/** * Return a Struts ActionForward given a ViewDescriptor. We need to add all * attributes from the ViewDescriptor as request attributes. */ private ActionForward toActionForward(ViewDescriptor viewDescriptor, ActionMapping mapping, HttpServletRequest request) { if (viewDescriptor != null) { WebUtils.exposeRequestAttributes(request, viewDescriptor.getModel()); ActionForward forward = mapping.findForward(viewDescriptor.getViewName()); if (forward != null) { // the 1.2.1 copy constructor would ideally be better to use, but is not Struts 1.1 compatible forward = new ActionForward(forward.getName(), forward.getPath(), viewDescriptor.isRedirect(), forward.getModule()); } else { forward = new ActionForward(viewDescriptor.getViewName(), viewDescriptor.isRedirect()); } forward.freeze(); return forward; } else { return null; } }
Keith Donald
Core Spring Development Team
Thanks Keith,
Have left work so I will try this in the morning.
Jim
I tried using your fix with struts 1.1, now it fails at forward.getModule()
/home/riyer/source/HEAD/src/org/springframework/webflow/struts/FlowAction.java:181: cannot find symbol
symbol : method getModule()
location: class org.apache.struts.action.ActionForward
forward = new ActionForward(forward.getName(), forward.getPath(), viewDescriptor.isRedirect(), forward.getModule());
^
/home/riyer/source/HEAD/src/org/springframework/webflow/struts/FlowAction.java:181: internal error; cannot instantiate ActionForward(java.lang.String,java.lang.String,bo olean,boolean) at org.apache.struts.action.ActionForward to ()
forward = new ActionForward(forward.getName(), forward.getPath(), viewDescriptor.isRedirect(), forward.getModule());
^
2 errors
BUILD FAILED
Another struts1.1 related exception
[org.springframework.web.struts.SpringBindingAction Form/getActionMessages] <MsgText: Unhandled java.lang.NoSuchMethodError: org.apache.struts.action.ActionMessage.<init>(Ljav a/lang/String;Z)V> <ThreadID: 13> <SessionID: 0000000077a86e593feb3c29136bfe6e3f95b7aba4241c60> <RequestURI: /spring/sellItem.do> <ExceptionLine: 150>
>> Exception: java.lang.NoSuchMethodError: org.apache.struts.action.ActionMessage.<init>(Ljav a/lang/String;Z)V
>> at org.springframework.web.struts.SpringBindingAction Form.getActionMessages(SpringBindingActionForm.jav a:150)
>> at org.springframework.web.struts.SpringBindingAction Form.expose(SpringBindingActionForm.java:130)
>> at org.springframework.webflow.struts.FlowAction$1.re questProcessed(FlowAction.java:163)
>> at org.springframework.webflow.execution.FlowExecutio nListenerList.fireRequestProcessed(FlowExecutionLi stenerList.java:208)
>> at org.springframework.webflow.execution.impl.FlowExe cutionImpl.signalEvent(FlowExecutionImpl.java:344)
>> at org.springframework.webflow.execution.FlowExecutio nManager.onEvent(FlowExecutionManager.java:431)
>> at org.springframework.webflow.struts.FlowAction.exec ute(FlowAction.java:128)
>> at org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:484)
>> at com.wm.weblib.struts.action.BaseRequestProcessor.p rocessActionPerform(BaseRequestProcessor.java:243)