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

[jsr372-experts] [1361-FlowStackAndFlowScopedBeans] PROPOSAL

From: Edward Burns <edward.burns_at_oracle.com>
Date: Tue, 10 Feb 2015 13:29:55 -0800

Hello Volunteers,

Issue [3680-NestedFlowProblems] came up on the tracker recently. I'm
prettry sure Leonardo has already raised this. Here is the problem.

{quote}
Consider having some flows in application, for example PersonListFlow,
PersonDetailFlow, AddressDetailFlow

Example:
1) enter person list - flow PersonListFlow

2) enter person detail - flow PersonDetailFlow

3) enter address detail - flow AddressDetailFlow

4) go to another person living on the same address -> flow
PersonDetailFlow. Flow stack would be:

PersonListFlow
PersonDetailFlow
AddressDetailFlow
PersonDetailFlow

Problem there is that FlowScoped ManagedBean is created for flow ID
"PersonDetailFlow" and is shared with two instances of PersonDetailFlow
in flow stack. In other words, data would be shared and after returning
to first flow PersonDetailFlow instance they will be corrupted for the
first person.
{quote}

The problem is the CDI context impl has no way to know that last call
into PersonDetailFlow is a new flow-call and thus the FlowScoped beans
from the previous invocation are visible. This is bad. The simplest
fix is to expose the flow depth on the FlowHandler. This suggestion
from Ren Zhijun on the JSF implementation team allows the context to
disambiguate this case. Here is the proposal:

M jsf-api/src/main/java/javax/faces/flow/FlowHandler.java

- Add new method

     /**
+ * <p class="changed_added_2_3">Return the stack depth of flows at the point in time
+ * of invocation. For backward compatibility with older implementations,
+ * a default implementation is provided that returns 0.</p>
+ *
+ * @param context the {_at_code FacesContext} for the current request.
+ *
+ * @since 2.3
+ */
+ public int getCurrentFlowDepth(FacesContext context) {

Thanks,

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