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

        Jack Van Ooststroom created issue -
        Jack Van Ooststroom made changes -
        Field Original Value New Value
        Assignee Jack van Ooststroom [ jack.van.ooststroom ]
        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.
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #27964 Tue Feb 21 15:12:40 MST 2012 jack.van.ooststroom Fixed JIRA ICE-7772 : FacesContext.getCurrentInstance() should not be used in static context
        Files Changed
        Commit graph MODIFY /icefaces3/branches/icefaces-3.0.x-maintenance/icefaces/compat/components/src/main/java/com/icesoft/faces/component/selectinputdate/SelectInputDateRenderer.java
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #27971 Wed Feb 22 09:02:10 MST 2012 jack.van.ooststroom Fixed JIRA ICE-7772 : FacesContext.getCurrentInstance() should not be used in static context
        Files Changed
        Commit graph MODIFY /icefaces3/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/selectinputdate/SelectInputDateRenderer.java
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #27972 Wed Feb 22 09:03:50 MST 2012 jack.van.ooststroom Fixed JIRA ICE-7772 : FacesContext.getCurrentInstance() should not be used in static context
        Files Changed
        Commit graph MODIFY /icefaces3/branches/icefaces-3.0.x-maintenance/icefaces/samples/core/auction/src/main/java/org/icefaces/demo/auction/view/controllers/IntervalPushRenderer.java
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #27973 Wed Feb 22 09:05:38 MST 2012 jack.van.ooststroom Fixed JIRA ICE-7772 : FacesContext.getCurrentInstance() should not be used in static context
        Files Changed
        Commit graph MODIFY /icefaces3/trunk/icefaces/samples/core/auction/src/main/java/org/icefaces/demo/auction/view/controllers/IntervalPushRenderer.java
        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.
        Jack Van Ooststroom made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Ken Fyten made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          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: