users@javaserverfaces-spec-public.java.net

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

From: David Schneider <david.schneider_at_oracle.com>
Date: Thu, 03 Jan 2013 10:12:29 -0700

Hi Nicolas,

You shouldn't need to use the viewId of the page from from_b in your
navigation rule. Instead you should use the ID of the flow-call node in
flow_a, "callB" in your case. I might even go so far as to say it's a
bug if the navigation rules in flow_a worked using the viewId from flow_b.

As for including navigation cases inside the flow-call element I'm not
sure I'm keen on the idea. The reason is typically NavigationHandler
implementations collect all the navigation rules up front and place them
into an optimal data structure so navigation handling is fast. Having
navigation cases defined elsewhere that are only valid in a particular
situation complicates life for the navigation handler.

Dave

On 1/3/2013 4:09 AM, Nicolas Romanetti wrote:
> 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 <mailto: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
> <mailto: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/
> <https://svn.java.net/svn/mojarra%7Esvn/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/