users@javaserverfaces-spec-public.java.net

[jsr344-experts mirror] [jsr344-experts] [730-Flows] OutcomeTarget flow navigation (clientWindowTransition() also handle navigation)

From: Leonardo Uribe <lu4242_at_gmail.com>
Date: Sun, 10 Mar 2013 22:09:24 -0500

Hi

I have been checking the proposal for OutcomeTarget navigation in deep. In few
words, the critical point is what clientWindowTransition() should do and how
to encode GET links properly.

Let's consider again this use case :

(suppose the flow document id is flowDoc2)

    <faces-flow-definition id="flow2">
        <flow-return id="exit2">
            <navigation-case>
                <from-outcome>exit1</from-outcome>
            </navigation-case>
        </flow-return>
    </faces-flow-definition>

(suppose the flow document id is flowDoc1)

    <faces-flow-definition id="flow1">
        <flow-return id="exit1">
            <navigation-case>
                <from-outcome>mainpage</from-outcome>
            </navigation-case>
        </flow-return>
    </faces-flow-definition>

Suppose we are in /flow2/mypage.xhtml and there is a link to exit the flow. How
it should looks like? according to what I can deduct from the spec it should
be something like this:

http://localhost:8080/myapp/mainpage.xhtml?jffi=exit2&jftfdi=flowDoc2

In theory the link should work as long as the flow stack is:

flow2
flow1
root

But what happen if I copy the link into a new browser tab? The stack is empty,
but I'm asking to exit flow2, which does not have sense. Has the link enough
information to decide if this case is valid? probably the fact that the stack
is empty suggest something's wrong, and clientWindowTransition() should do some
kind of validation (the javadoc does not has it), but the link does not say
where this call comes from.

The weird part is the current javadoc of clientWindowTransition() interprets
this case as if we are entering to "exit2" flow. Why? because sourceFlow is
null and targetFlow is exit2.

The point is the "outcome" also requires the sourceFlow to be complete. In this
way, the algorithm can say:

"... ok so we want to navigate from this node, let's check first if the
context is correct ..."

"... if the context is not correct throw some exception because the link is
invalid ..."

"... if the context is correct do the navigation from this node to the target
view like handleNavigation() does, and optionally check if the url match with
the calculated one when the link was rendered, otherwise force a redirect
so the url can be corrected ..."

A correctly generated link could say this:

http://localhost:8080/myapp/mainpage.xhtml?sourceFlow=flow2&jftfdi=flowDoc2&fromOutcome=exit2

In common words it says "from flow2 in flowDoc2 execute the navigation starting
from exit2 and the target view will be mainpage.xhtml"

Who decide whether to enter or exit the flow? the node(s) traversed that can be
1, 2 or many more.

In conclusion, clientWindowTransition() should do two things:

1. Check the context where this link is being called is correct.
2. Execute a flow navigation from a node to a target view. It could be an start
node, a switch, a method node, a return node, whatever.

regards,

Leonardo Uribe