javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-3132

NullPointerException when navigation rule use <if> and has no <from-outcome> element.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.2.6
    • Component/s: navigation
    • Labels:
      None
    • Environment:

      windows, wildfly 8 Rc1.

      Description

      I have this rule:
      <navigation-rule>
      <from-view-id>/login.xhtml</from-view-id>
      <navigation-case>
      <from-action>#

      {authenticationBean.login}

      </from-action>
      <if>#

      {userCredential.userLoggedIn}

      </if>
      <to-view-id>/index.xhtml</to-view-id>
      <redirect/>
      </navigation-case>
      </navigation-rule>

      as you see, my expectation is, after login successfully, system will redirect to index.xhtml page.
      JSF Specs said that: "To match an outcome value of null, the <from-outcome>must be absent and the <if>element present"

      but in NagigationHandlerImpl class, from line 1264, determineViewFromActionOutcome() method
      if (match) {
      if (cncHasCondition && Boolean.FALSE.equals(cnc.getCondition(ctx)))

      { match = false; }

      else {
      toFlowDocumentId = (null != cnc.getToFlowDocumentId()) ? cnc.getToFlowDocumentId() : toFlowDocumentId;
      if (null != toFlowDocumentId)

      { FlowHandler fh = ctx.getApplication().getFlowHandler(); result.isFlowEntryFromExplicitRule = null != fh.getFlow(ctx, toFlowDocumentId, outcome); }

      return result;
      }
      }

      match is true, and cncHasCondition is true, and cnc.getCondition(ctx) returns true too.
      then, toFlowDocumentId will be not changed (and equals to "")
      then, system call getFlow() method with outcome as the third parameter. In this case outcome is null already.
      and inside getFlow() method, it requires output must be not null.
      @Override
      public Flow getFlow(FacesContext context, String definingDocumentId, String id) {
      Util.notNull("context", context);
      Util.notNull("definingDocumentId", definingDocumentId);
      Util.notNull("id", id);
      Flow result = null;
      Map<String, Flow> mapsForDefiningDocument = flows.get(definingDocumentId);

      if (null != mapsForDefiningDocument)

      { result = mapsForDefiningDocument.get(id); }

      return result;
      }

      Then I always get NullPointerException.

      Please help to check it.

        Activity

        Hide
        Manfred Riem added a comment -

        Can you give us a simple reproducer so we can make sure we understand the problem correctly? Please send it to issues@javaserverfaces.java.net.

        Show
        Manfred Riem added a comment - Can you give us a simple reproducer so we can make sure we understand the problem correctly? Please send it to issues@javaserverfaces.java.net.
        Hide
        Ed Burns added a comment -

        This is sample code for this issue.
        Flow is:

        as I stated nagivation rules in faces-config.xml

        faces-config.xml
        <navigation-rule>
        <from-view-id>*</from-view-id>
        <navigation-case>
        <from-action>#{demoBean.login}</from-action>
        <if>#{demoBean.userLoggedIn}</if>
        <to-view-id>/index.xhtml</to-view-id>
        <redirect/>
        </navigation-case>
        <navigation-case>
        <from-action>#{demoBean.login}</from-action>
        <if>#{!demoBean.userLoggedIn}</if>
        <to-view-id>/login.xhtml</to-view-id>
        </navigation-case>
        </navigation-rule>
        

        I expected that after click Login button, I will be redirect to index.xhtml
        page instead.

        Show
        Ed Burns added a comment - This is sample code for this issue. Flow is: Open http://localhost:8080/NestedCompositeSample/login.jsf Click login button. In Console I got: Caused by: java.lang.NullPointerException: Argument Error: Parameter id is null at com.sun.faces.util.Util.notNull(Util.java:448) [jsf-impl-2.2.4-jbossorg-1.jar:] as I stated nagivation rules in faces-config.xml faces-config.xml <navigation-rule> <from-view-id>*</from-view-id> <navigation- case > <from-action>#{demoBean.login}</from-action> < if >#{demoBean.userLoggedIn}</ if > <to-view-id>/index.xhtml</to-view-id> <redirect/> </navigation- case > <navigation- case > <from-action>#{demoBean.login}</from-action> < if >#{!demoBean.userLoggedIn}</ if > <to-view-id>/login.xhtml</to-view-id> </navigation- case > </navigation-rule> I expected that after click Login button, I will be redirect to index.xhtml page instead.
        Hide
        Ed Burns added a comment -

        You cite some spec text, apparently by paraphrasing. If I am interpreting your paraphrasing correctly, the exact spec text you are citing is this text from section 7.4 NavigationHandler 7.4.1 Overview

        As of JSF 2.0, the NavigationHandler is consulted even on a null outcome, but under this circumstance it only checks navigation cases that do not specify an outcome (no <from-outcome>) and have a condition expression (specified with <if>). This is the only case where the same view (and component tree) is re-used.

        It seems the "This is only the case where the same view (and component tree) is re-used." is coming into play in this case. In this case, you are navigating to a different view. That would mean the rule cited does not apply. I'm continuing to investigate this, though.

        Show
        Ed Burns added a comment - You cite some spec text, apparently by paraphrasing. If I am interpreting your paraphrasing correctly, the exact spec text you are citing is this text from section 7.4 NavigationHandler 7.4.1 Overview As of JSF 2.0, the NavigationHandler is consulted even on a null outcome, but under this circumstance it only checks navigation cases that do not specify an outcome (no <from-outcome>) and have a condition expression (specified with <if>). This is the only case where the same view (and component tree) is re-used. It seems the "This is only the case where the same view (and component tree) is re-used." is coming into play in this case. In this case, you are navigating to a different view. That would mean the rule cited does not apply. I'm continuing to investigate this, though.
        Hide
        Ed Burns added a comment -

        Happily, it seems like this is not immediately related to the spec text, becaus I am seeing the "Argument Error: Parameter id is null" message. Continuing to investigate.

        Show
        Ed Burns added a comment - Happily, it seems like this is not immediately related to the spec text, becaus I am seeing the "Argument Error: Parameter id is null" message. Continuing to investigate.
        Hide
        Ed Burns added a comment -

        Stripped down sample with no external dependencies aside from the JavaEE 7 jar.

        Show
        Ed Burns added a comment - Stripped down sample with no external dependencies aside from the JavaEE 7 jar.
        Show
        Ed Burns added a comment - Safe to close when < http://slc03qna.us.oracle.com:7070/hudson/view/Mojarra%202.2.x/job/2_2_x-gf-3_1_2_2-no-cluster/483/ >, < http://slc03qna.us.oracle.com:7070/hudson/view/Mojarra%202.2.x/job/2_2_x-gf-4_0-no-cluster/248/ >, and < http://hudson-sca.us.oracle.com/view/MOJARRA_ALL/job/MOJARRA_2_2X_ROLLING_GLASSFISH_3_1_2_2_NO_CLUSTER/359/ > are clean.
        Hide
        Ed Burns added a comment -

        All required jobs are clean.

        Show
        Ed Burns added a comment - All required jobs are clean.

          People

          • Assignee:
            Ed Burns
            Reporter:
            ducva
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 48 minutes
              48m