jsr372-experts@javaserverfaces-spec-public.java.net

[jsr372-experts] Re: [jsr372-experts mirror] Re: [1361-FlowStackAndFlowScopedBeans] PROPOSAL

From: Leonardo Uribe <leonardo.uribe_at_irian.at>
Date: Wed, 11 Feb 2015 00:07:48 -0500

Hi

The default behavior in MyFaces is, when you call the same flow twice,
the algorithm close the existing flows on the stack and restart a new
flow in the same position as the first one was.

In that case:

PersonListFlow
PersonDetailFlow
AddressDetailFlow

If the user enters to PersonDetailFlow again the stack will look like this:

PersonListFlow
PersonDetailFlow*

where PersonDetailFlow* is a new flow.

You can have nested flows, but you can never enter into the same flow.

There is a method called:

Flow.getClientWindowFlowId(ClientWindow curWindow)

which derives an unique identifier for the flow based on the
clientWindow id. The problem is CDI use that method as a key to get
into the right flow scope map and get the bean instance.

We need something different here, because the right way to see the stack is:

PersonListFlow
PersonDetailFlow(A)
AddressDetailFlow
PersonDetailFlow(B)

So, in this case, PersonDetailFlow is special because it is not the
same to edit Person A or Person B. What I mean, is the "contextual"
flow id, which helps to identify it in a unique way is a composition
between the clientWindowId, the flowId, and something else provided by
the user somehow.

The problem with use the flow depth is that you can enter over and
over into the same flow just clicking on the button and going back.
Instead, I would like to propose something like this in
faces-config.xml:

        <flow-call id="call_person_detail_flow">
            <flow-reference>
                <flow-id>PersonDetailFlow</flow-id>
                <flow-context-id>#{...}<flow-context-id>
            </flow-reference>
        </flow-call>

The flow-context-id (or maybe flow-header-id or any other name) could
be something that identify the flow and that can be used by the
navigation algorithm to decide when to exit from the flow or not (the
EL is evaluated when the algorithm enter into the flow and the value
is saved in the stack).

Please note in JSF 2.2 there is a relationship between the client
window id and the flow id (only one flow instance of the same type per
window).

regards,

Leonardo Uribe

2015-02-10 17:35 GMT-05:00 Edward Burns <edward.burns_at_oracle.com>:
>>>>>> On Tue, 10 Feb 2015 15:58:56 -0600, manfred riem <manfred.riem_at_oracle.com> said:
>
> MR> Hi Ed,
> MR> Looking at it I think this could be locally solved by making sure the
> MR> FlowCDIContext keeps track of the depth by adding one when entering a
> MR> flow and subtracting one when exiting a flow.
>
> That's a good idea.
>
> MR> Note I have not prototyped it but all the call sites to the
> MR> FlowScopeMapHelper are in FlowCDIContext.
>
> If you get some time, please do try and see if that approach will work.
> I'd rather not have to add that method.
>
> Ed
>
> --
> | edward.burns_at_oracle.com | office: +1 407 458 0017
> | 19 days til DevNexus 2015
> | 29 days til JavaLand 2015
> | 39 days til CONFESS 2015