ICEfaces
  1. ICEfaces
  2. ICE-7772

FacesContext.getCurrentInstance() should not be used in static context

    Details

      Description

      FacesContext.getCurrentInstance() should not be used in static context. WebSphere Application Server 8 seems to complain about this. The issue is timing related. We should go through the code and make sure the usage is only done in non-static context to be safe.

        Activity

        Hide
        Jack Van Ooststroom added a comment -

        To give an example. The SelectInputDateRenderer contains the following:

        private static final String ID_SUFFIX = UINamingContainer.getSeparatorChar(FacesContext.getCurrentInstance()) + "j_idcl";

        Currently, WAS8 can complain about this causing the ICEfaces application not to run.

        Checking the usage of ID_SUFFIX, it only seems to be used in non-static context. The solution in this case is simple as we can remove the static keyword for the ID_SUFFIX and solve this particular usage. However, other static usages might need more work.

        We use FacesContext.getCurrentInstance() extensively.

        Show
        Jack Van Ooststroom added a comment - To give an example. The SelectInputDateRenderer contains the following: private static final String ID_SUFFIX = UINamingContainer.getSeparatorChar(FacesContext.getCurrentInstance()) + "j_idcl"; Currently, WAS8 can complain about this causing the ICEfaces application not to run. Checking the usage of ID_SUFFIX, it only seems to be used in non-static context. The solution in this case is simple as we can remove the static keyword for the ID_SUFFIX and solve this particular usage. However, other static usages might need more work. We use FacesContext.getCurrentInstance() extensively.
        Hide
        Jack Van Ooststroom added a comment -

        We should fix these on a case-by-case basis if other instances are encountered. A few have been identified and fixed. Marking this one as FIXED.

        Show
        Jack Van Ooststroom added a comment - We should fix these on a case-by-case basis if other instances are encountered. A few have been identified and fixed. Marking this one as FIXED.

          People

          • Assignee:
            Jack Van Ooststroom
            Reporter:
            Jack Van Ooststroom
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: