Announcement Announcement Module
Collapse
No announcement yet.
SWF 2 plugin for Struts 2 (Struts 2 + SWF 2 Intregration) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SWF 2 plugin for Struts 2 (Struts 2 + SWF 2 Intregration)

    Hi! I would like to know if there's a Struts 2 Plugin to use SWF 2 with it. I know about the "Struts 2 Webflow" Plugin, but it's implemented for SWF 1.

    I refactored it to the SWF 2 classes and methods but now I'm having a problem I can't solve. SWF 2 always tries to resolve a view-state using a FlowViewResolver, which tries to find .jsp files with the view-state name. I tried building a "Struts2ViewResolver". I'm not that familiar with SWF 2 internals so you're right to assume I had no success with that too :P

    Could someone help me to refactor the "Struts 2 Webflow" plugin to SWF 2 or point me a Struts 2 Plugin that already do that?

    BTW, I know pretty much nothing about Spring MVC and I don't know much about SWF too. I'm developing a Framework for web applications which uses Struts 2 as controller and must have a Webflow feature (it's its key feature). As soon as I implement this (Struts2+SWF2) I'll start playing around and learning about SWF =P

    Struts 2 Webflow Plugin page: http://cwiki.apache.org/S2PLUGINS/sp...ow-plugin.html

    A little overview how this plugin works (or should work):

    I make a Struts 2 mapping for my flow, like this:
    Code:
    <action name="exampleFlow" class="com.googlecode.struts2webflow.FlowAction">
        <param name="flowId">swfExampleFlow</param>
    
        <result name="s2_viewInput">/jsp/input.jsp</result>
        <result name="s2_showResult">/jsp/congratulations.jsp</result>
    </action>

    And a SWF 2 mapping like this:
    Code:
    <!-- Content of the /WEB-INF/flows/swfExampleFlow.xml file -->
    <flow all-that-stuff-here="is hidden">
        <var name="ex" class="example.flow.ExampleFlow" />
    
        <view-state id="flowStart" view="s2_viewInput">
            <transition on="submit" to="someFlowAction" />
        </view-state>
    
        <action-state id="someFlowAction">
            <evaluate expression="flowScope.ex.magic()" result="res" />
            <transition on="OK" to="flowEnd" />
            <transition on="ERROR" to="flowStart" />
        </action-state>
    
        <end-state id="flowEnd" view="s2_showResult" />
    </flow>
    And, to make things short, what the plugin does is "translate" SWF view-states into Struts 2 Action's Results. Got it?

    (Sorry if I'm using wrong terminology for things... please correct me if I am).

    Thanks for any help

  • #2
    Almost Got it

    I got it to work perfectly if instead of passing a view-state name on the view attribute, I put a /path/to/file.jsp.

    I.E.:
    Code:
    <view-state id="firstStep" view="/jsp/firstStep.jsp">
        <transition on="submit" to="secondStep" />
    </view-state>
    But what I really want is that the view attribute points to a Struts 2 Result, not a JSP. Struts' Results can be redirect to other actions and do other things I can't pointing to a .jsp =P

    Comment


    • #3
      Did you get this to work?

      I've been trying to get this working for ages by upgrading the Struts2Webflow plugin.

      However, I hit a serious problem with the SWF2 integration. In SWF1 it was easy to get access to the internal flow scope using ActionContext. However, in SWF2 you can't seem to do this anymore and I can't find a way of getting access to the internal flow scope.

      You can access the external flow scope, but that doesn't contain the attributes from the latest request. There's the Spring RequestContextHolder, but that doesn't work unless it's in the same thread, so you can't access it from a struts2 interceptor.

      Did you manage to get a working solution? I would love to be able to release the plugin with SWF2 integration

      Comment


      • #4
        Yeah, I did it =P

        Yeah, I've managed to do it. For now it's working just like I want it to work =)

        I've used that SWF-Struts2 Plugin as a starting point and worked out a almost brand new plugin :P - I just reused some wrapper classes and adapted the "core code" of the plugin: the execute() method of the FlowAction class.

        There's a known bug that I'm not sure if it's just SWF's way of reporting stuff or a real bug. If your flow starts with a action-state it'll throw a Exception because he couldn't find a map (says something about "map[[empty]]" or something like that)... dunno what that mean for now (I'm not really up to chasing this now, I'll do it later, hehe). I've managed to sort a workaround though (use a <on-entry> with a <evaluate> on it).

        I'll work on making Struts' validation and injection scheme work on your "flow object" (dunno the right name... it's that "flowScope.variableName" you use to do stuff at <evaluate>). You know, executing validate() before the action execution and making "<input name='something.property'>" into yourObj.getSomething().setProperty(inputValue). But I'm tell you I don't even know if it's possible :P (perhaps extending FlowAction will do the trick...)

        The SWF data (like ${flowExecutionUrl} and other stuff) is accessible at the final pages either through EL or OGNL (using "#attr.flowExecutionUrl"). You can build forms integrating Struts tags and SWF data. Still need a <s:hidden name="executor" value="%{#attr.flowExecutionKey}" /> on every page though ;P - and a quirk I did't solved it: the "eventId" parameter must be named "_eventId", just like SWF1.

        I created a custom ViewResolver that I use to sort of resolve which'll be the FlowAction result.

        If you're interested in knowing more about it - and how to make it work - send me a e-mail: rafael_at_infoway-pi_dot_com_dot_br

        Comment


        • #5
          Reply?

          g0dkar I tried emailing you but got no reply - could you get back to me or let me know how you got this working?

          I'd really like to get the plugin working so others can use it

          Comment


          • #6
            Sorry!

            Sorry if you couldn't reach me through that mail =/

            Try [email protected] (no "anti-spam speak" this time, hehe), it's my personal e-mail which I'm logged pretty much 24/7. That other one ([email protected]) is my work e-mail :P

            Or you could post your e-mail so that I can contact you :P

            Comment

            Working...
            X