MyFaces Core
  1. MyFaces Core
  2. MYFACES-1579

VariableResolver throws IllegalStateException because scope is unknown

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.0
    • Fix Version/s: 1.2.0
    • Component/s: JSR-252
    • Labels:
      None

      Description

      VariableResolverImpl tries to determine if it was invoked through the faces chain or jsp chain by looking for an attribute (Scope.getClassName()) in the RequestMap. However, that attribute is only set during the span of a call to FacesCompositeELResolver.getValue(). See FacesCompositeELResolver#invoke(), which calls setScope() and then unsetScope().

      Therefore the following code always throws IllegalStateException

      VariableResolver resolver = application.getVariableResolver();
      Object result = resolver.resolveVariable(facesContext, "param");

      because when VariableResolverImpl.resolveVariable() looks for the scope in the request map (which happens outside the getValue() call) its always null.

        Activity

        Hide
        Mathias Broekelmann added a comment -

        Application.getVariableResolver should return a resolver which delegates to the application el resolver. I fixed this and added a test for it. Thanks Paul!

        Show
        Mathias Broekelmann added a comment - Application.getVariableResolver should return a resolver which delegates to the application el resolver. I fixed this and added a test for it. Thanks Paul!
        Hide
        Paul McMahan added a comment -

        I took a stab at creating a patch for this which passes the test cases. But I can't claim to totally understand all the scenarios under which VariableResolver.resolveVariable() might be called, so the patch needs careful review and probably some rework. I'm also not real fond of downcasting to get the resolver's scope but couldn't think of a better way without a lot of code refactoring (my understanding of the legacy support that VariableResolver will provide is limited).

        Show
        Paul McMahan added a comment - I took a stab at creating a patch for this which passes the test cases. But I can't claim to totally understand all the scenarios under which VariableResolver.resolveVariable() might be called, so the patch needs careful review and probably some rework. I'm also not real fond of downcasting to get the resolver's scope but couldn't think of a better way without a lot of code refactoring (my understanding of the legacy support that VariableResolver will provide is limited).

          People

          • Assignee:
            Mathias Broekelmann
            Reporter:
            Paul McMahan
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development