Uploaded image for project: 'PUBLIC - Liferay Faces'
  1. PUBLIC - Liferay Faces
  2. FACES-3101

ClassCastException thrown by FacesContextHelperUtil.getRequestQueryStringParameter(String name)

    Details

      Description

      Whenever you call

       

      FacesContextHelperUtil.getRequestQueryStringParameter(name)
      

      It throws ClassCastException. I dug throw the code in the old version (when it worked fine), I will try to explain in stack calls.

       

      Old:

      You got here through instance in LiferayFacesContextImpl

       

      FacesContextHelperImpl.getRequestQueryString(name)
      FacesContextHelperPortletImpl.getRequestQueryString() //this call is done by polymorphim via the upper method

       

      In the new FacesContextHelperUtil though, it creates instance via factory. It creates FacesContextHelperPortletImpl as it should. Now the problem lies within wrapper. Class 

      FacesContextHelperPortletImpl, does not have method getRequestQueryString(name), overriden so that means it is just gonna call getWrapped() - which returns the FacesContextHelperImpl instance. That means the polymorphic call which was there before (now the target is method getRequestQueryString(facesContext)) never happens since we just called getRequestQueryString(name) on original wrapped instance.

      Link on the call itself.

       

      If this doesnt explain enough I can add some graphics which explains it better.

       

      My workaround is to register new FacesContextHelperFactory and which then returns MyFacesContextHelperPortletImpl which extends FacesContextHelperImpl. This way the polymorphic calls works again. I am not sure if this is how it should be done, since there are wrappers for this kind of stuff but it works just fine. 

      I think the solution should be in FacesContextHelperPortletImpl to override method getRequestQueryString(name) itself.

       

      I didnt run into any other issues yet but I could see problem with this again whenever there is expected polymorphic call but there is no polymorphism. 

       

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Packages

                Version Package
                portal-1.0.1
                portal-2.0.1
                portal-3.0.1