Announcement Announcement Module
Collapse
No announcement yet.
Tips or articles on integrating SWF into struts Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Take a look a the 'BirthDate' sample application, which illustrates Struts integration. Also take a look at the JavaDoc of the FlowAction class.

    Erwin

    Comment


    • #3
      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

      Comment


      • #4
        What version of Struts are you using?

        We tested birthdate on 1.2.7.

        Keith

        Comment


        • #5
          1.1

          Will SWF work with 1.1?

          Jim

          Comment


          • #6
            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

            Comment


            • #7
              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 :-)

              Comment


              • #8
                Thanks Keith,

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

                Jim

                Comment


                • #9
                  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

                  Comment


                  • #10
                    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)

                    Comment


                    • #11
                      Ugh, I guess relying on Strut's JavaDoc @since tags is not enough...

                      I'll see what I can do here.

                      Comment


                      • #12
                        This should be fixed now for Struts 1.1. You'll need Spring 1.2.3

                        Comment

                        Working...
                        X