users@javaserverfaces-spec-public.java.net

[jsr344-experts mirror] Re: jsf2.2 feedback: give control back to calling flow

From: Nicolas Romanetti <nromanetti_at_jaxio.com>
Date: Thu, 3 Jan 2013 12:09:11 +0100

  Hello David,

This is clear, thank you. I could make it work but not exactly as you
answer suggests.

I have tried to use <j:navigation-rule> in the <f:metadata> but apparently
this tag is not defined and from the Java FlowBuilder, there is no way to
set any navigation rule.

So I ended up declaring a navigation-rule in the faces-config.xml, as
follow:
(note: I changed the flow id from flow-b to flow_b to avoid xsd complaints
later on)

<navigation-rule>
   <from-view-id>/flow_b/next_b.xhtml</from-view-id>
   <navigation-case>
     <from-outcome>outcomeFromB</from-outcome>
     <to-view-id>/flow_a/next_b.xhtml</to-view-id>
   </navigation-case>
</navigation-rule>

It worked! When I get back to the calling flow I can see the flowScope
variable I had set before calling flow_b.
However, I think it is weird to have to know the view id of the called
flow.... (here /flow_b/next_b.xhtml)

*I would prefer something more generic (as your response suggests) but I
could not find how to declare it. I tried this without success (in
faces-config.xml)
*
<navigation-rule>
* <from-view-id>/flow_a/callB</from-view-id><!-- callB being the flow-call
id in flow_a -->
* <navigation-case>
    <from-outcome>outcomeFromB</from-outcome>
    <to-view-id>/flow_a/next_b.xhtml</to-view-id>
  </navigation-case>
</navigation-rule>


*But ideally I would prefer to declare this rule inside the flow-call node,
for example:*


<j:flow-call id="callB">

  <j:faces-flow-reference>

    <j:faces-flow-id>flow_b</j:faces-flow-id>

  </j:faces-flow-reference>

  <j:outbound-parameter>

    <j:name>param1</j:name>

    <j:value>param1ValueFromA</j:value>
  </j:outbound-parameter>

  <j:outbound-parameter>

    <j:name>param2</j:name>

    <j:value>param2ValueFromA</j:value>

  </j:outbound-parameter>
* <navigation-case>*
* <from-outcome>outcomeFromB</from-outcome>*
* <to-view-id>next_b</to-view-id>*
* </navigation-case>*
</j:flow-call>

What do you think?

Nicolas.


On Thu, Jan 3, 2013 at 12:28 AM, David Schneider <david.schneider_at_oracle.com>
wrote:
>
> Hi Nicolas,
>
> The called flow does not need to know what flow called it. Think of each
> flow as a graph of nodes and the edges between the nodes are defined by
the
> navigation cases.
>
> When a flow returns control to a calling flow it also returns an outcome
> value. The navigation rules/cases in the calling flow are then evaluated
> using the outcome and id of the flow-call node to determine what comes
next
> in the calling flow. You won't see what comes next in the flow-call node,
> you'll need to look at the navigation cases since they're what defines the
> edges in the navigation graph. This allows the caller to navigate to any
> page or node following the return based on the outcome value.
>
> Does that make sense?
>
> Dave
>
>
> On 01/02/2013 11:33 AM, nromanetti_at_jaxio.com wrote:
>>
>> Hello,
>>
>> I am studying the latest JSF2.2 spec and the examples provided here:
>> https://svn.java.net/svn/mojarra~svn/trunk/test/web-profile/flow/
>>
>> I could not find how a calling flow can take the control back once the
>> called flow returns.
>>
>> I am used to Spring Web Flow... So I was expecting something like this.
>>
>> In "flow b" definition:
>> ================
>>
>> <j:flow-return id="taskFlowReturn1">
>> <outbound-parameter>
>> <name>resultFromFlowB</name>
>> <value>The returned Value</value>
>> </outbound-parameter>
>> </j:flow-return>
>>
>> <!-- note that I have not specified any navigation case as I want to
>> go back to the calling flow (the current spec does not allow this)
>> From flow B I should not know who called flow-b, I just want to
>> give the control back... -->
>>
>>
>> In "flow a" definition:
>> ================
>>
>> <j:flow-call id="callB">
>> <j:faces-flow-reference>
>> <j:faces-flow-id>flow-b</j:faces-flow-id>
>> </j:faces-flow-reference>
>> <j:outbound-parameter>
>> <j:name>param1</j:name>
>> <j:value>param1Value</j:value>
>> </j:outbound-parameter>
>> <j:outbound-parameter>
>> <j:name>param2</j:name>
>> <j:value>param2Value</j:value>
>> </j:outbound-parameter>
>>
>> <j:on-flow-return id="taskFlowReturn1">
>> <!-- Here I would know that flow-b returned using
>> the 'taskFlowReturn1' node. Knowning this I could
>> decide what to do... for example call a
>> method, select an appropriate node etc..
>> -->
>> </j:on-flow-return>
>> </j:flow-call>
>>
>>
>> I think it is an essential feature, the called flow should not have to
>> know who called it. And the caller should know what was the exit node
>> of the called flow.
>>
>> I was relying extensively on such feature when using Spring Web Flow +
>> JSF.
>>
>> Am I missing something?
>>
>> Hope this helps.
>>
>> Nicolas
>> --
>> twitter: @nromanetti
>
>



-- 
Nicolas Romanetti
06 18 65 03 89
twitter: @nromanetti
http://www.jaxio.com/
http://www.springfuse.com/