javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-3130

NavigationHandlerImpl differs from specification if a matching navigation-case element was located

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.4
    • Fix Version/s: 2.3.0-m02, 2.3.0
    • Component/s: navigation
    • Labels:
      None
    • Environment:

      RI 2.2.4 with Tomcat 7

      Description

      The spec for navigation says in chapter 7.4.2

      If a matching <navigation-case> element was located, proceed as follows.
      If the <to-view-id> element is the id of a flow, discover that flow's start node and resolve it to a vdl view
      identifier by following the algorithm in Section 7.4.2.1 "Requirements for Explicit Navigation in Faces Flow Call
      Nodes other than ViewNodes"
      If the <to-view-id> element is a non-view flow node, resolve it to a vdl view identifier by following the
      algorithm in Section 7.4.2.1 "Requirements for Explicit Navigation in Faces Flow Call Nodes other than
      ViewNodes".

      Now we have the following button
      <h:commandButton value="submit" action="enterFlow" />

      So with the following navigation rule in faces-config.xml I would expect to open 'myFlow' because the navigation case matches to the outcome 'enterFlow' and the spec says we use the to-view-id to get the flow-id.
      <navigation-rule>
      <from-view-id>/index.xhtml</from-view-id>
      <navigation-case>
      <from-outcome>enterFlow</from-outcome>
      <to-view-id>myFlow</to-view-id>
      <to-flow-document-id />
      <redirect />
      </navigation-case>
      </navigation-rule>

      But the NavigationHandlerImpl uses the from-outcome and navigates to a flow called enterFlow that I don't have.
      This is because of two implementation details in NavigationHandlerImpl.

      1. private CaseStruct determineViewFromActionOutcome(FacesContext ctx, Set<NavigationCase> caseSet, String fromAction, String outcome, String toFlowDocumentId)
      ...
      result.isFlowEntryFromExplicitRule = null != fh.getFlow(ctx, toFlowDocumentId, outcome);

      Line 1271 uses the outcome to get the flow and not result.viewId

      2. private CaseStruct getViewId(FacesContext ctx, String fromAction, String outcome, String toFlowDocumentId)
      ...
      // and try to call into the flow
      caseStruct = findFacesFlowCallMatch(ctx, fromAction, outcome, toFlowDocumentId);

      Line 495 also uses the outcome to overwrite the CaseStruct. So again we search for the flow 'enterFlow' and not 'myFlow'.

      The second part of the spec 'if the <to-view-id> element is a non-view flow node' is also not working.

      If we have the following flow definition:
      <flow-definition id="myFlow">
      <switch id="switch">
      <case>
      <if>#

      {myBean.check}</if>
      <from-outcome>doSomething</from-outcome>
      </case>
      <default-outcome>gotoEnd</default-outcome>
      </switch>
      <navigation-rule>
      <from-view-id>*</from-view-id>
      <navigation-case>
      <from-outcome>testcase</from-outcome>
      <to-view-id>switch</to-view-id>
      <redirect />
      </navigation-case>
      </navigation-rule>
      </flow-definition>

      <h:commandButton value="submit" action="testcase" />

      If I click the submit button we get the navigation-case with outcome 'testcase' and to-view-id 'switch'. So the to-view-id is a non view node and spec would have us to resolve the node and handle the response with the switch element and finally go to 'doSomething' if #{myBean.check}

      is true. But we are redirected to the switch.xhtml that doesn't exist.
      Since I didn't use <to-flow-document-id /> in the definition the CaseStruct is not touched after the first match. If I use to-flow-document-id we would use the outcome and not the to-view-id for the new navigation. This is because of the bug mentioned above. But at some point I read that using to-flow-document-id inside a flow should not work (don't remember where). Because we call other flows only with flow-call.

        Issue Links

          Activity

          Hide
          TobiasTRD added a comment -

          Yes the second part comes only if you are navigating inside a flow.
          So this works only (or not with the bug) if you are on the example page of myFlow.

          Show
          TobiasTRD added a comment - Yes the second part comes only if you are navigating inside a flow. So this works only (or not with the bug) if you are on the example page of myFlow.
          Hide
          Ed Burns added a comment -

          Hello Zhijun,

          It's possible your other fixes for flow have fixed this, so please do test it with the latest trunk.

          Thanks,

          Ed

          Show
          Ed Burns added a comment - Hello Zhijun, It's possible your other fixes for flow have fixed this, so please do test it with the latest trunk. Thanks, Ed
          Hide
          ren.zhijun.oracle added a comment -

          Hi Ed and Manfred and Tobias,

          Please help to review the code change.

          BR,
          Zhijun

          Show
          ren.zhijun.oracle added a comment - Hi Ed and Manfred and Tobias, Please help to review the code change. BR, Zhijun
          Hide
          Ed Burns added a comment -

          Hello Zhijun,

          Can you please put a comment on your new method convertToViewIdToFlowOrNodeId() explaining why simply trimming off the text after the last '/' is sufficient to perform the conversion mentioned in the method name? Please add that comment and you have r=edburns.

          All the tests ran locally clean for me.

          Show
          Ed Burns added a comment - Hello Zhijun, Can you please put a comment on your new method convertToViewIdToFlowOrNodeId() explaining why simply trimming off the text after the last '/' is sufficient to perform the conversion mentioned in the method name? Please add that comment and you have r=edburns. All the tests ran locally clean for me.
          Hide
          ren.zhijun.oracle added a comment -

          comments fixed, and code committed:

          rzhijun-mac:trunk zhijun$ svn commit -m "JAVASERVERFACES-3130:NavigationHandlerImpl differs from specification if a matching navigation-case element was located" --username ren.zhijun.oracle
          Sending jsf-ri/src/main/java/com/sun/faces/application/NavigationHandlerImpl.java
          Adding test/javaee6web/flowTraversalCombinations/src/main/java/com/sun/faces/test/javaee6web/flowtraversalcombinations/Issue3130Bean.java
          Adding test/javaee6web/flowTraversalCombinations/src/main/webapp/WEB-INF/faces-config.xml
          Adding test/javaee6web/flowTraversalCombinations/src/main/webapp/flow-for-issue-3130
          Adding test/javaee6web/flowTraversalCombinations/src/main/webapp/flow-for-issue-3130/DestinationView.xhtml
          Adding test/javaee6web/flowTraversalCombinations/src/main/webapp/flow-for-issue-3130/PageShouldNotBe.xhtml
          Adding test/javaee6web/flowTraversalCombinations/src/main/webapp/flow-for-issue-3130/SourceView.xhtml
          Adding test/javaee6web/flowTraversalCombinations/src/main/webapp/flow-for-issue-3130/flow-for-issue-3130-flow.xml
          Sending test/javaee6web/flowTraversalCombinations/src/main/webapp/index.xhtml
          Adding test/javaee6web/flowTraversalCombinations/src/test/java/com/sun/faces/test/javaee6web/flowtraversalcombinations/Issue3130IT.java
          Transmitting file data .........
          Committed revision 14457.

          Show
          ren.zhijun.oracle added a comment - comments fixed, and code committed: rzhijun-mac:trunk zhijun$ svn commit -m " JAVASERVERFACES-3130 :NavigationHandlerImpl differs from specification if a matching navigation-case element was located" --username ren.zhijun.oracle Sending jsf-ri/src/main/java/com/sun/faces/application/NavigationHandlerImpl.java Adding test/javaee6web/flowTraversalCombinations/src/main/java/com/sun/faces/test/javaee6web/flowtraversalcombinations/Issue3130Bean.java Adding test/javaee6web/flowTraversalCombinations/src/main/webapp/WEB-INF/faces-config.xml Adding test/javaee6web/flowTraversalCombinations/src/main/webapp/flow-for-issue-3130 Adding test/javaee6web/flowTraversalCombinations/src/main/webapp/flow-for-issue-3130/DestinationView.xhtml Adding test/javaee6web/flowTraversalCombinations/src/main/webapp/flow-for-issue-3130/PageShouldNotBe.xhtml Adding test/javaee6web/flowTraversalCombinations/src/main/webapp/flow-for-issue-3130/SourceView.xhtml Adding test/javaee6web/flowTraversalCombinations/src/main/webapp/flow-for-issue-3130/flow-for-issue-3130-flow.xml Sending test/javaee6web/flowTraversalCombinations/src/main/webapp/index.xhtml Adding test/javaee6web/flowTraversalCombinations/src/test/java/com/sun/faces/test/javaee6web/flowtraversalcombinations/Issue3130IT.java Transmitting file data ......... Committed revision 14457.

            People

            • Assignee:
              ren.zhijun.oracle
              Reporter:
              TobiasTRD
            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: