Results 1 to 10 of 11

Thread: Accessing a flow execution from outside Spring Web Flow in 2.0

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Posts
    3

    Default Accessing a flow execution from outside Spring Web Flow in 2.0

    Hi,

    I'm currently Migrating our application from SWF 1.0 to 2.0.5. And I'm now facing difficulty to accessing a flow execution from outside Spring Web Flow in 2.0.
    Basically, I wish to add the data in flowMap into FlowExecution active session scope so that it can be carried by flow.
    This is the sample code for SWF 1.0.

    private final Map<String, Object> flowMap;
    ...
    ...
    protected final String triggerEvent(final String pEventId) {
    final FacesContext faces = FacesContext.getCurrentInstance();
    final FlowExecutionHolder holder = FlowExecutionHolderUtils.getFlowExecutionHolder(fa ces);
    for (final String k : this.flowMap.keySet()) {
    holder.getFlowExecution().getActiveSession().getSc ope().put(k,this.flowMap.ge(k));
    }
    return pEventId;
    }

    However, in SWF 2.0.5, FlowExecutionHolderUtils has been removed.
    Is there any other way that I can get the current FlowExecution via a standalone class?

    Best Regards,
    Jianhua

  2. #2

    Default

    there is a el variable flowExecutionContext
    you can pass it to your method

  3. #3
    Join Date
    Dec 2008
    Posts
    3

    Default

    Thanks for your reply. However, I cannot use any tag library or xml configuration to pass in the values since they are dynamically generated from database and stored into Map object.
    In this case, the application allows user to search a list of products, then this list of products will be stored in to the Map objects. I wish to keep this list of products into the flowExecution scope MutableAttributeMap, so in every page within this webflow, the searched product list can be accessed.

    The code I posted worked perfect with SWF 1.0. Now what I wish to know is how to access a FlowExecution or FlowExecutor out side SWF 2.0 like what I have done in SWF 1.0.

    Thanks!
    Jianhua

  4. #4

    Red face

    i think you want to access a map sotred in the flowScope
    use the evaluate will do

    Code:
    <evaluate result="flowScope.yourMap" expression="yourService.createYourMapMethod()" />
    yourService can be any bean in your application context


    If i didn't say clear enough, suggest you look into the el part of the swf reference

  5. #5
    Join Date
    Apr 2007
    Posts
    276

    Default

    Were you able to figure out how to get the flowExecution form outside the flow in swf2?

    Quote Originally Posted by jhshen View Post
    Thanks for your reply. However, I cannot use any tag library or xml configuration to pass in the values since they are dynamically generated from database and stored into Map object.
    In this case, the application allows user to search a list of products, then this list of products will be stored in to the Map objects. I wish to keep this list of products into the flowExecution scope MutableAttributeMap, so in every page within this webflow, the searched product list can be accessed.

    The code I posted worked perfect with SWF 1.0. Now what I wish to know is how to access a FlowExecution or FlowExecutor out side SWF 2.0 like what I have done in SWF 1.0.

    Thanks!
    Jianhua

  6. #6
    Join Date
    Nov 2006
    Location
    Boston, MA
    Posts
    303

    Default

    I think posts like the one that started this thread are very confusing and dangerous. Other people who search the forum looking for answers or advice may run into such thread and assume that it actually discusses a serious legitimate design issue...

    Maybe I misunderstand something, but it seems that what the original poster is trying to do is just plain wrong, in the first place. Why would anyone - in an SWF application - obtain a list of objects outside the flow and then try to put it into the flow scope from the outside? Don't sprinkle your logic between multiple modules, tiers, and technologies! Haven't enough been said about the importance of consolidating logic? In the above example, all he needed to do was inject the Product service (POJO) into the Action class that backs a certain state in the flow. In that action - e.g. in the execute() method, invoke the service API that retrieves the list of products, and place that list into the flow scope (or, perhaps, conversation scope - if appropriate.) The scopes are available to any SWF action class via the RequestContext parameter passed to the action methods.

    How difficult would that be? No, you first have to come up with an insane design, create tons of hurdles for yourself, and then spend weeks trying to figure out how to overcome the obstacles you have created... Kids, don't do this! If you find yourselves looking for some bizarre crafty solution to a seemingly simple problem, don't blame the framework. Chances are, your design is a mess...

  7. #7
    Join Date
    Apr 2007
    Posts
    276

    Default

    Quote Originally Posted by constv View Post
    Why would anyone - in an SWF application - obtain a list of objects outside the flow and then try to put it into the flow scope from the outside?
    Perhaps when you need to use real popups. Have yet to see a solution where you real popups (no just divs in the same page) work elegantly within the same flow.

Tags for this Thread

Posting Permissions

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