Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Tips or articles on integrating SWF into struts

  1. #1
    Join Date
    Dec 2004
    Location
    London
    Posts
    51

    Default Tips or articles on integrating SWF into struts

    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

  2. #2
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    Take a look a the 'BirthDate' sample application, which illustrates Struts integration. Also take a look at the JavaDoc of the FlowAction class.

    Erwin

  3. #3
    Join Date
    Dec 2004
    Location
    London
    Posts
    51

    Default

    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:

    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)

    Any ideas why this wouldn't just work out of the box?

    Jim

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    What version of Struts are you using?

    We tested birthdate on 1.2.7.

    Keith
    Keith Donald
    Core Spring Development Team

  5. #5
    Join Date
    Dec 2004
    Location
    London
    Posts
    51

    Default

    1.1

    Will SWF work with 1.1?

    Jim

  6. #6
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    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:
    Code:
    	private ActionForward toActionForward&#40;ViewDescriptor viewDescriptor, ActionMapping mapping,
    			HttpServletRequest request&#41; &#123;
    		if &#40;viewDescriptor != null&#41; &#123;
    			WebUtils.exposeRequestAttributes&#40;request, viewDescriptor.getModel&#40;&#41;&#41;;
    			ActionForward forward = mapping.findForward&#40;viewDescriptor.getViewName&#40;&#41;&#41;;
    			if &#40;forward != null&#41; &#123;
    				forward = new ActionForward&#40;forward&#41;;
    			&#125;
    			else &#123;
    				forward = new ActionForward&#40;viewDescriptor.getViewName&#40;&#41;&#41;;
    			&#125;
    			forward.setRedirect&#40;viewDescriptor.isRedirect&#40;&#41;&#41;;
    			forward.freeze&#40;&#41;;
    			return forward;
    		&#125;
    		else &#123;
    			return null;
    		&#125;
    	&#125;
    Maybe there is a 1.1 compatible solution...?

    Keith
    Keith Donald
    Core Spring Development Team

  7. #7
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Okay, I committed the following fix:

    Code:
    	/**
    	 * Return a Struts ActionForward given a ViewDescriptor. We need to add all
    	 * attributes from the ViewDescriptor as request attributes.
    	 */
    	private ActionForward toActionForward&#40;ViewDescriptor viewDescriptor, ActionMapping mapping,
    			HttpServletRequest request&#41; &#123;
    		if &#40;viewDescriptor != null&#41; &#123;
    			WebUtils.exposeRequestAttributes&#40;request, viewDescriptor.getModel&#40;&#41;&#41;;
    			ActionForward forward = mapping.findForward&#40;viewDescriptor.getViewName&#40;&#41;&#41;;
    			if &#40;forward != null&#41; &#123;
    				// the 1.2.1 copy constructor would ideally be better to use, but is not Struts 1.1 compatible
    				forward = new ActionForward&#40;forward.getName&#40;&#41;, forward.getPath&#40;&#41;, viewDescriptor.isRedirect&#40;&#41;, forward.getModule&#40;&#41;&#41;;
    			&#125;
    			else &#123;
    				forward = new ActionForward&#40;viewDescriptor.getViewName&#40;&#41;, viewDescriptor.isRedirect&#40;&#41;&#41;;
    			&#125;
    			forward.freeze&#40;&#41;;
    			return forward;
    		&#125;
    		else &#123;
    			return null;
    		&#125;
    	&#125;
    See PR5 tommorrow, test now please :-)
    Keith Donald
    Core Spring Development Team

  8. #8
    Join Date
    Dec 2004
    Location
    London
    Posts
    51

    Default

    Thanks Keith,

    Have left work so I will try this in the morning.

    Jim

  9. #9
    Join Date
    Jul 2005
    Location
    Foster City, CA
    Posts
    10

    Default

    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

  10. #10
    Join Date
    Jul 2005
    Location
    Foster City, CA
    Posts
    10

    Default

    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)

Similar Threads

  1. Replies: 7
    Last Post: Aug 6th, 2006, 10:12 PM
  2. problem on integrating Struts with Spring
    By borland2004 in forum Web
    Replies: 1
    Last Post: Sep 16th, 2005, 09:13 PM
  3. Replies: 1
    Last Post: Aug 17th, 2005, 04:17 AM
  4. Replies: 3
    Last Post: Jul 22nd, 2005, 06:26 AM
  5. Replies: 10
    Last Post: Nov 2nd, 2004, 09:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •