ICEfaces
  1. ICEfaces
  2. ICE-5825

Several remaining xhtml compliance issues with compat components

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-Alpha3
    • Fix Version/s: 2.0.0
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      ICEfaces 2 JSF 2
    • Affects:
      Documentation (User Guide, Ref. Guide, etc.), Sample App./Tutorial, Compatibility/Configuration
    • Workaround Exists:
      Yes
    • Workaround Description:
      Hide
      Add the f:view tag with the following attribute to ensure that the content type is text/html:

      <f:view contentType="text/html">
      Show
      Add the f:view tag with the following attribute to ensure that the content type is text/html: <f:view contentType="text/html">

      Description

      Up to Alpha 3 release, the ICEfaces response writer (DOMResponseWriter) was returned hardcoded values for:

      content type: text/html
      encoding: UTF-8

      While this covers a wide range of use cases, it's not adaptable to change by application developers. Changes to the DOMResponseWriter in ICE-5664 - to provide better support for determining the proper content type and encoding - makes for a more compatible ICEfaces experience.

      However, now that the values are no longer hard coded, browsers can potentially handle the markup differently based on what they accept and prefer. For example Chrome and Safari currently prefer "application/xhtml+xml" over "text/html":

          Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

      whereas Firefox prefers "text/html"

          Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

      This is all fine (and better explained here - http://www.w3.org/TR/xhtml-media-types/) except that if the content type "application/xhtml-xml" is returned, then the default namespace must also be included or the page will not render correctly:

      <html xmlns="http://www.w3.org/1999/xhtml">

      So we need to ensure that we document this requirement and that our example applications are properly adjusted to ensure the default namespace is included in our page markup.

        Activity

        Hide
        Deryk Sinotte added a comment -

        Improving subject line

        Show
        Deryk Sinotte added a comment - Improving subject line
        Hide
        Deryk Sinotte added a comment -

        In testing the changes to the ResponseWriters (ICE-5664), the compatible version of Component Showcase was showing a couple of major issues.

        One was that the Calendar demo would not render properly when the menu link was clicked. This only affected WebKit based browsers (Chrome and Safari). Firefox worked fine. I could see that the update was being retrieved but not applied. Debugging showed that WebKit considered the update to be malformed XML. I guessed that it might be the   entities and removed them from the SelectInputDateRenderer class and that worked.

        The other was that Google Maps throwing a JavaScript exception on the initial load of the first page. Some Googling turned up a blog (http://www.jroller.com/HazemBlog/entry/uncaught_typeerror_object_a_document) that stated the following regarding the exact same error:

        Uncaught TypeError: Object #<a Document#> has no method 'write'

        Error Conditions:
        This issue happens when you use GMaps4JSF with Google Chrome (also Safari) in Facelets XHTML files (The default PDL for JSF 2.0). Actually this issue generally happens when you make make any include to Google Maps inside XHTML files:
        <script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAAxrVS1QxlpJHXxQ2Vxg2bJBQdkFK-tWRbPPQS4ACM1pq_e-PltxQXeyH20wQuqDaQ_6EM5UeGGVpnIw"> </script>

        Solution:
        Just set the content type to "text/html":
        <f:view contentType="text/html">

        Adding the contentType to the f:view tag did solve the problem. Basically, it overrides the main issue outlined in the original problem description - that some browsers "prefer" application-xhtml and will therefore have that sent back as the content type. Since xhtml is stricter about many things, I've adjusted what I could to make things more compliant. However, GMaps won't work without this setting. I've applied it to the page-template.xhtml file of the Component Showcase and GMaps does work again. This is likely something we'll need to note as a general solution to problems with strict XHTML adherence.

        Show
        Deryk Sinotte added a comment - In testing the changes to the ResponseWriters ( ICE-5664 ), the compatible version of Component Showcase was showing a couple of major issues. One was that the Calendar demo would not render properly when the menu link was clicked. This only affected WebKit based browsers (Chrome and Safari). Firefox worked fine. I could see that the update was being retrieved but not applied. Debugging showed that WebKit considered the update to be malformed XML. I guessed that it might be the   entities and removed them from the SelectInputDateRenderer class and that worked. The other was that Google Maps throwing a JavaScript exception on the initial load of the first page. Some Googling turned up a blog ( http://www.jroller.com/HazemBlog/entry/uncaught_typeerror_object_a_document ) that stated the following regarding the exact same error: Uncaught TypeError: Object #<a Document#> has no method 'write' Error Conditions: This issue happens when you use GMaps4JSF with Google Chrome (also Safari) in Facelets XHTML files (The default PDL for JSF 2.0). Actually this issue generally happens when you make make any include to Google Maps inside XHTML files: <script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAAxrVS1QxlpJHXxQ2Vxg2bJBQdkFK-tWRbPPQS4ACM1pq_e-PltxQXeyH20wQuqDaQ_6EM5UeGGVpnIw"> </script> Solution: Just set the content type to "text/html": <f:view contentType="text/html"> Adding the contentType to the f:view tag did solve the problem. Basically, it overrides the main issue outlined in the original problem description - that some browsers "prefer" application-xhtml and will therefore have that sent back as the content type. Since xhtml is stricter about many things, I've adjusted what I could to make things more compliant. However, GMaps won't work without this setting. I've applied it to the page-template.xhtml file of the Component Showcase and GMaps does work again. This is likely something we'll need to note as a general solution to problems with strict XHTML adherence.
        Hide
        Deryk Sinotte added a comment -

        For educational purposes, here's the diff of the changes that I had made to the renderer that allowed it to be XHTML compliant (remove the   entities).

        Index: components/src/main/java/com/icesoft/faces/component/selectinputdate/SelectInputDateRenderer.java
        ===================================================================
        — components/src/main/java/com/icesoft/faces/component/selectinputdate/SelectInputDateRenderer.java (revision 21788)
        +++ components/src/main/java/com/icesoft/faces/component/selectinputdate/SelectInputDateRenderer.java (working copy)
        @@ -1030,7 +1030,7 @@
        table.appendChild(tr1);
        }

        • writeCell(domContext, facesContext, writer, inputComponent, " ",
          + writeCell(domContext, facesContext, writer, inputComponent, " ",
          null, inputComponent.getDayCellClass(), tr1, null,
          (weekStartsAtDayIndex + i) % 7,
          timeKeeper, months, weekdaysLong, converter);
          @@ -1136,7 +1136,7 @@
          if ((columnIndexCounter != 0) && (tr2 != null)) {
          for (int i = columnIndexCounter; i < weekdays.length; i++) {
          writeCell(domContext, facesContext, writer,
        • inputComponent, " ", null,
          + inputComponent, " ", null,
          inputComponent.getDayCellClass(), tr2, null,
          (weekStartsAtDayIndex + i) % 7,
          timeKeeper, months, weekdaysLong, converter);
        Show
        Deryk Sinotte added a comment - For educational purposes, here's the diff of the changes that I had made to the renderer that allowed it to be XHTML compliant (remove the   entities). Index: components/src/main/java/com/icesoft/faces/component/selectinputdate/SelectInputDateRenderer.java =================================================================== — components/src/main/java/com/icesoft/faces/component/selectinputdate/SelectInputDateRenderer.java (revision 21788) +++ components/src/main/java/com/icesoft/faces/component/selectinputdate/SelectInputDateRenderer.java (working copy) @@ -1030,7 +1030,7 @@ table.appendChild(tr1); } writeCell(domContext, facesContext, writer, inputComponent, " ", + writeCell(domContext, facesContext, writer, inputComponent, " ", null, inputComponent.getDayCellClass(), tr1, null, (weekStartsAtDayIndex + i) % 7, timeKeeper, months, weekdaysLong, converter); @@ -1136,7 +1136,7 @@ if ((columnIndexCounter != 0) && (tr2 != null)) { for (int i = columnIndexCounter; i < weekdays.length; i++) { writeCell(domContext, facesContext, writer, inputComponent, " ", null, + inputComponent, " ", null, inputComponent.getDayCellClass(), tr2, null, (weekStartsAtDayIndex + i) % 7, timeKeeper, months, weekdaysLong, converter);
        Hide
        Deryk Sinotte added a comment -

        I've adjusted the DOMUtils class where we were handling the logic to translate coded entities that are what are generally expected for XHTML (e.g.  ) to the friendly HTML versions of the entities:

        Index: src/main/java/org/icefaces/util/DOMUtils.java
        ===================================================================
        — src/main/java/org/icefaces/util/DOMUtils.java (revision 21794)
        +++ src/main/java/org/icefaces/util/DOMUtils.java (revision 21795)
        @@ -546,11 +546,11 @@
        } else if (ch == '\'')

        { buffer.append("'"); }

        else if (ch == '"')

        { - buffer.append("""); + buffer.append("""); }

        else if (ch >= 0xA0 && ch <= 0xff)

        { - buffer.append("&").append(escapeAnsi(ch)).append(";"); + buffer.append("&#").append(Integer.toString(ch)).append(";"); }

        else if (ch == 0x20AC)

        {//special case for euro symbol - buffer.append("€"); + buffer.append("€"); }

        else

        { buffer.append(ch); }

        We do this because now that we adjust to the proper content type, WebKit browsers can be very strict about the XHTML and most HTML entities are not supported. A summary of the issue can be found here:

        http://techtrouts.com/webkit-entity-nbsp-not-defined-convert-html-entities-to-xml/

        Show
        Deryk Sinotte added a comment - I've adjusted the DOMUtils class where we were handling the logic to translate coded entities that are what are generally expected for XHTML (e.g.  ) to the friendly HTML versions of the entities: Index: src/main/java/org/icefaces/util/DOMUtils.java =================================================================== — src/main/java/org/icefaces/util/DOMUtils.java (revision 21794) +++ src/main/java/org/icefaces/util/DOMUtils.java (revision 21795) @@ -546,11 +546,11 @@ } else if (ch == '\'') { buffer.append("'"); } else if (ch == '"') { - buffer.append("""); + buffer.append("""); } else if (ch >= 0xA0 && ch <= 0xff) { - buffer.append("&").append(escapeAnsi(ch)).append(";"); + buffer.append("&#").append(Integer.toString(ch)).append(";"); } else if (ch == 0x20AC) {//special case for euro symbol - buffer.append("€"); + buffer.append("€"); } else { buffer.append(ch); } We do this because now that we adjust to the proper content type, WebKit browsers can be very strict about the XHTML and most HTML entities are not supported. A summary of the issue can be found here: http://techtrouts.com/webkit-entity-nbsp-not-defined-convert-html-entities-to-xml/
        Hide
        Deryk Sinotte added a comment -

        Where possible, I've adjusted the demo pages and the code to be more XHTML compliant so that WebKit browsers will play nicely with ICEfaces applications. The fallback for those applications can't be adjusted to provide stricter XHTML content is to mark the contentType as text/html as noted in a previous comment.

        Show
        Deryk Sinotte added a comment - Where possible, I've adjusted the demo pages and the code to be more XHTML compliant so that WebKit browsers will play nicely with ICEfaces applications. The fallback for those applications can't be adjusted to provide stricter XHTML content is to mark the contentType as text/html as noted in a previous comment.
        Hide
        Deryk Sinotte added a comment -

        Re-opening the case.

        To fix ICE-5891, it was necessary to back out some changes that originally helped with XHTML compliance. They related to the case of tag names (e.g. DIV vs div) in some of the bridge code. With the changes applied, some components stopped working properly in component showcase. There was no in-depth analysis to find out why changing the case to lowercase affected only a few of these components (Menu, Split Pane Panel). At this point, Component Showcase is currently marked to be output as "text/html" and the changes have been reverted.

        Show
        Deryk Sinotte added a comment - Re-opening the case. To fix ICE-5891, it was necessary to back out some changes that originally helped with XHTML compliance. They related to the case of tag names (e.g. DIV vs div) in some of the bridge code. With the changes applied, some components stopped working properly in component showcase. There was no in-depth analysis to find out why changing the case to lowercase affected only a few of these components (Menu, Split Pane Panel). At this point, Component Showcase is currently marked to be output as "text/html" and the changes have been reverted.
        Hide
        Deryk Sinotte added a comment -

        Attaching the patch of the original changes that were made to the bridge code to adjust the case of various tags. The changes the scriptaculous code may have been unnecessary as the library itself may have been accomodating the case properly depending on how it was used.

        Show
        Deryk Sinotte added a comment - Attaching the patch of the original changes that were made to the bridge code to adjust the case of various tags. The changes the scriptaculous code may have been unnecessary as the library itself may have been accomodating the case properly depending on how it was used.
        Hide
        Deryk Sinotte added a comment -

        Assigning to Ken for re-assignment.

        Show
        Deryk Sinotte added a comment - Assigning to Ken for re-assignment.
        Hide
        Deryk Sinotte added a comment -

        As an example, one of the component related changes that I didn't make but alluded to in the notes was to the SelectInputDateRenderer. Similar to the adjustments we made for the DOMUtils for entities:

        writeCell(domContext, facesContext, writer, inputComponent, " ",

        becomes

        writeCell(domContext, facesContext, writer, inputComponent, " ",

        Show
        Deryk Sinotte added a comment - As an example, one of the component related changes that I didn't make but alluded to in the notes was to the SelectInputDateRenderer. Similar to the adjustments we made for the DOMUtils for entities: writeCell(domContext, facesContext, writer, inputComponent, " ", becomes writeCell(domContext, facesContext, writer, inputComponent, " ",
        Hide
        yip.ng added a comment -

        Revision: 23190


        Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/ext/renderkit/TableRenderer.java
        Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/outputprogress/OutputProgress.java
        Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/outputprogress/OutputProgressRenderer.java
        Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/paneldivider/PanelDividerRenderer.java
        Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/selectinputdate/SelectInputDateRenderer.java

        Show
        yip.ng added a comment - Revision: 23190 Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/ext/renderkit/TableRenderer.java Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/outputprogress/OutputProgress.java Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/outputprogress/OutputProgressRenderer.java Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/paneldivider/PanelDividerRenderer.java Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/selectinputdate/SelectInputDateRenderer.java
        Hide
        Ken Fyten added a comment -

        Re-open to also include all the sample apps.

        Show
        Ken Fyten added a comment - Re-open to also include all the sample apps.
        Hide
        yip.ng added a comment -

        Revision: 23202


        Modified : /icefaces2/trunk/icefaces/compat/component-metadata/src/main/java/com/icesoft/metadata/test/DefaultValueTest.java
        Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/paneltabset/PanelTabSetRenderer.java
        Modified : /icefaces2/trunk/icefaces/compat/core/src/main/java/com/icesoft/faces/context/effects/JavascriptContext.java
        Modified : /icefaces2/trunk/icefaces/compat/core/src/main/java/com/icesoft/jasper/Constants.java
        Modified : /icefaces2/trunk/icefaces/compat/samples/auctionMonitor/src/com/icesoft/applications/faces/auctionMonitor/beans/UserBean.java
        Modified : /icefaces2/trunk/icefaces/compat/samples/auctionMonitor/web/WEB-INF/faces-config.xml
        Modified : /icefaces2/trunk/icefaces/compat/samples/auctionMonitor/web/auctionMonitor.html
        Modified : /icefaces2/trunk/icefaces/compat/samples/compat-basic/web/icefaces-subtree.xhtml
        Modified : /icefaces2/trunk/icefaces/compat/samples/compat-basic/web/icefaces.xhtml
        Modified : /icefaces2/trunk/icefaces/compat/samples/compat-basic/web/nonicefaces.xhtml

        Show
        yip.ng added a comment - Revision: 23202 Modified : /icefaces2/trunk/icefaces/compat/component-metadata/src/main/java/com/icesoft/metadata/test/DefaultValueTest.java Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/paneltabset/PanelTabSetRenderer.java Modified : /icefaces2/trunk/icefaces/compat/core/src/main/java/com/icesoft/faces/context/effects/JavascriptContext.java Modified : /icefaces2/trunk/icefaces/compat/core/src/main/java/com/icesoft/jasper/Constants.java Modified : /icefaces2/trunk/icefaces/compat/samples/auctionMonitor/src/com/icesoft/applications/faces/auctionMonitor/beans/UserBean.java Modified : /icefaces2/trunk/icefaces/compat/samples/auctionMonitor/web/WEB-INF/faces-config.xml Modified : /icefaces2/trunk/icefaces/compat/samples/auctionMonitor/web/auctionMonitor.html Modified : /icefaces2/trunk/icefaces/compat/samples/compat-basic/web/icefaces-subtree.xhtml Modified : /icefaces2/trunk/icefaces/compat/samples/compat-basic/web/icefaces.xhtml Modified : /icefaces2/trunk/icefaces/compat/samples/compat-basic/web/nonicefaces.xhtml

          People

          • Assignee:
            yip.ng
            Reporter:
            Deryk Sinotte
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: