ICEfaces
  1. ICEfaces
  2. ICE-5613

ICEfaces requires h:head and h:body tags to properly add resources

    Details

    • Workaround Exists:
      Yes
    • Workaround Description:
      Ensure that h:head and h:body tags are present in all pages that use ICEfaces.

      Description

      There is a basic assumption with JSF 2 that when resources (typically references to JavaScript files) are targetted at areas like "head" and "body" that the page contains the actual "h:head" and "h:body" tags respectively. Without these tags, the basic ICEfaces bridge code cannot be made available. However, we have other areas of the code (e.g. ice.captureSubmit, deltaSubmit) that can add inline scripts that rely on these core resource files being available. The end result is that the scripts can get added to the page but the main files are never loaded and the browser complains that some JavaScript references (e.g. "ice") are undefined and no ICEfaces functionality is available.

      For portlets, the same basic logic holds true. Although portlets don't typically allow rendering directly to the head or body, it's the responsibility of the portlet bridge to override the standard JSF behaviour and use other means (potentially vendor specific means) to ensure that calls to render code to the head or body are handled appropriately.

      It is possible to have ICEfaces available but not want to use it on certain pages - in other words, it should be possible to mix ICEfaces and non-ICEfaces pages together within one application or portlet .war file so we need to ensure that in cases where h:head and h:body tags are not available, we don't render out any scripts that rely on resources targetted to those areas.

        Issue Links

          Activity

          Deryk Sinotte created issue -
          Deryk Sinotte made changes -
          Field Original Value New Value
          Salesforce Case []
          Fix Version/s 2.0-Alpha3 [ 10032 ]
          Assignee Priority P2
          Assignee Deryk Sinotte [ deryk.sinotte ]
          Deryk Sinotte made changes -
          Link This issue blocks ICE-5565 [ ICE-5565 ]
          Deryk Sinotte made changes -
          Link This issue blocks ICE-5543 [ ICE-5543 ]
          Deryk Sinotte made changes -
          Link This issue blocks ICE-5568 [ ICE-5568 ]
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #21191 Mon Apr 12 11:10:34 MDT 2010 deryk.sinotte ICE-5613: do not render out ICEfaces scripts if h:head and h:body are not present
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/resources/META-INF/faces-config.xml
          Commit graph ADD /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/event/HeadBodyListener.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/util/EnvUtils.java
          Hide
          Deryk Sinotte added a comment -

          Added detection for the h:head and h:body components and disables all ICEfaces script insertions if they are not both there. It uses the HeadBodyListener class as a SystemEvent listener and modifies the EnvUtils.isICEfacesView() method to use this information.

          JSF 2.0 requires the h:head tag for the jsf.js resource if Ajax is enabled manually in an non-ICEfaces page so requiring the h:head tag seems reasonable. It's also required for the portlet bridge to be able to override the rendering of the h:head component so that resources that are required for all portlets only need to be added once and they can be properly inserted into the head of the portal page.

          We currently have some script snippets that get inserted into the body and so require the h:body tag as well (using root.addComponentResource(context, icefacesSetup, "body"). They contain information like the viewID which, in a portal page, will be different for each portlet so it's not currently possible to put it into the head only once. If we'd like to remove the h:body requirement we can discuss other options. For now, in order to pass the tests and to operate in the client properly when the bridge is not available, you need the h:head and h:body tags in the page and, if they are not there, then there is no ICEfaces support.

          There are still some kinks to work out around how to best do the detection of these components (there may be a JSF bug involved) and how to log/notify developers as to why ICEfaces has been disabled. I have some WARN level logging in there now but the EnvUtils.isICEfacesView method is called several times during processing of a single view so the logging is potentially dumped out several times.

          Show
          Deryk Sinotte added a comment - Added detection for the h:head and h:body components and disables all ICEfaces script insertions if they are not both there. It uses the HeadBodyListener class as a SystemEvent listener and modifies the EnvUtils.isICEfacesView() method to use this information. JSF 2.0 requires the h:head tag for the jsf.js resource if Ajax is enabled manually in an non-ICEfaces page so requiring the h:head tag seems reasonable. It's also required for the portlet bridge to be able to override the rendering of the h:head component so that resources that are required for all portlets only need to be added once and they can be properly inserted into the head of the portal page. We currently have some script snippets that get inserted into the body and so require the h:body tag as well (using root.addComponentResource(context, icefacesSetup, "body") . They contain information like the viewID which, in a portal page, will be different for each portlet so it's not currently possible to put it into the head only once. If we'd like to remove the h:body requirement we can discuss other options. For now, in order to pass the tests and to operate in the client properly when the bridge is not available, you need the h:head and h:body tags in the page and, if they are not there, then there is no ICEfaces support. There are still some kinks to work out around how to best do the detection of these components (there may be a JSF bug involved) and how to log/notify developers as to why ICEfaces has been disabled. I have some WARN level logging in there now but the EnvUtils.isICEfacesView method is called several times during processing of a single view so the logging is potentially dumped out several times.
          Deryk Sinotte made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #21196 Mon Apr 12 13:41:43 MDT 2010 deryk.sinotte ICE-5613: remove bad detection optimization
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/event/HeadBodyListener.java
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #21198 Mon Apr 12 14:15:31 MDT 2010 deryk.sinotte ICE-5613: check for null rendererTypes
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/event/HeadBodyListener.java
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #21206 Mon Apr 12 16:21:35 MDT 2010 deryk.sinotte ICE-5613: adjusted logging levels and location
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/util/EnvUtils.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/event/BridgeSetup.java
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #21232 Thu Apr 15 11:29:52 MDT 2010 deryk.sinotte ICE-5613: adjusted loggers to resolve to class rather than package
          Files Changed
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/context/DOMResponseWriter.java
          Commit graph MODIFY /icefaces/scratchpads/glimmer/core/src/main/java/org/icefaces/event/HeadBodyListener.java
          Ken Fyten made changes -
          Fix Version/s 2.0.0 [ 10230 ]
          Ken Fyten made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Assignee Priority P2

            People

            • Assignee:
              Deryk Sinotte
              Reporter:
              Deryk Sinotte
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: