[gatein-commits] gatein SVN: r2063 - portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Mar 9 13:03:41 EST 2010


Author: mwringe
Date: 2010-03-09 13:03:41 -0500 (Tue, 09 Mar 2010)
New Revision: 2063

Modified:
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
Log:
GTNPORTAL-764: Handle the script tag separately than the other tags when adding markup headers to a page. We need to have the script tag be not self closing (handled by the html method) and have all other tags close (handled by the xml method).

Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java	2010-03-09 17:38:10 UTC (rev 2062)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java	2010-03-09 18:03:41 UTC (rev 2063)
@@ -398,12 +398,24 @@
       {
          Transformer transformer = TransformerFactory.newInstance().newTransformer();
          transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
-         transformer.setOutputProperty(OutputKeys.METHOD, "html");
 
          for (Element element : extraMarkupHeaders)
          {
             DOMSource source = new DOMSource(element);
             StreamResult result = new StreamResult(new StringWriter());
+
+            // we want to ouput xhtml text that will still work on html browsers.
+            // In order to do this we need to have the script tag be not self closing
+            // which it will try and do with the xml or xhtml method. If we just use
+            // the html method then the other tags will not be closed.
+            if (element.getNodeName().equalsIgnoreCase("script"))
+            {
+               transformer.setOutputProperty(OutputKeys.METHOD, "html");
+            }
+            else
+            {
+               transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+            }
             transformer.transform(source, result);
             markupHeaders.add(result.getWriter().toString());
          }



More information about the gatein-commits mailing list