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

[jsr344-experts] Re: Attention Pivotal/SpringSource folks: Faces Flows and SWF

From: Leonardo Uribe <lu4242_at_gmail.com>
Date: Sun, 19 Jan 2014 20:06:38 -0500

Hi

Thanks Ed for create the issue. As a workaround the easiest way I
have found is create a custom ViewHandler and override
createView(...) method like this:

    @Override
    public UIViewRoot createView(FacesContext context, String viewId)
    {
        UIViewRoot root = super.createView(context, viewId);
        if (root != null)
        {
            FlowHandler flowHandler = context.getApplication().
getFlowHandler();
            if (flowHandler.isActive(context, "", "flow1") &&
                !viewId.startsWith("/flow1/"))
            {
                Flow flow = flowHandler.getFlow(context, "", "flow1");
                flowHandler.transition(context, flow, null, null, viewId);
            }
        }
        return root;
    }

The ideal state is have something in the spec to fix it, but for now I
think it is ok to suggest users to do this workaround.

This example has convinced me that the best for 2.2 is use the
"lax" mode as the default (as it is inside MyFaces), because with the
workaround you can easily fix the algorithm for the flows that requires
the "strict" mode. If "strict" mode is the default we cannot fix the
algorithm from outside, because the details about exit from the
flow automatically will be inside the JSF implementation.

regards,

Leonardo Uribe

2014/1/17 Edward Burns <edward.burns_at_oracle.com>:
>>>>>> On Thu, 16 Jan 2014 22:40:32 -0500, Leonardo Uribe <lu4242_at_gmail.com> said:
>
> LU> Hi
> LU> Just FYI, recently an user made a comment about a use case he has for
> LU> Faces Flow in MyFaces:
>
> LU> Subject: JSF 2.2 Exit Flow
>
> LU> "... I have an application that consists of a dropdown menu bar with
> LU> many menu items. Each menu item will initiate a new faces flow. This
> LU> is working correctly, however, once I am inside a flow, I would like
> LU> any click on a menu item to exit the current flow, and then start a
> LU> new one. There are dozens of menu items in the application, so I was
> LU> wondering if there is any way to have the current flow automatically
> LU> exit when a menu item is clicked without having to define a
> LU> flow-return for each menu item? ..."
>
> LU> What he is looking for is precisely what we are discussing here.
>
> LU> 1. Global navigation should still work even if the user enters into a flow.
> LU> 2. A navigation to a page outside a flow in some cases should trigger
> LU> an exit from the flow automatically, but in others that's not
> LU> necessary true.
>
> I tested this with the latest Mojarra and you are correct. Abandoning a
> flow while simultaneously entering another flow is not allowed.
> Currently you have to visit the unbounded flow first and then enter the
> new flow.
>
> I have opened spec issue 1253 on this and also ask for more feedback
> here if people think this should really be supported.
>
> Ed
>
> --
> | edward.burns_at_oracle.com | office: +1 407 458 0017
> | homepage: | http://ridingthecrest.com/
> | 24 Work Days Til DevNexus 2014
> | 41 Work Days Til JavaLand 2014