myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bom...@apache.org
Subject svn commit: r634005 - in /myfaces/tobago/branches/tobago-1.0.x: ./ core/src/main/java/org/apache/myfaces/tobago/util/ core/src/main/java/org/apache/myfaces/tobago/webapp/ theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarboro...
Date Wed, 05 Mar 2008 19:59:21 GMT
Author: bommel
Date: Wed Mar  5 11:59:14 2008
New Revision: 634005

URL: http://svn.apache.org/viewvc?rev=634005&view=rev
Log:
Merged revisions 634001 via svnmerge from 
https://svn.apache.org/repos/asf/myfaces/tobago/trunk

........
  r634001 | lofwyr | 2008-03-05 20:46:53 +0100 (Mi, 05 Mär 2008) | 1 line
  
  TOBAGO-629: ensure content type meta header (for WebSphere)
........

Modified:
    myfaces/tobago/branches/tobago-1.0.x/   (props changed)
    myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/util/ResponseUtils.java
    myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java

Propchange: myfaces/tobago/branches/tobago-1.0.x/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Mar  5 11:59:14 2008
@@ -1 +1 @@
-/myfaces/tobago/trunk:1-603371,609568-609629,612250-612251,612282,612518,613455,613939,614278,614291,614642,615257,616717,617876,618327,619122,619133,619933,619936,619947-619962,620088,620569,627768-627771
+/myfaces/tobago/trunk:1-603371,609568-609629,612250-612251,612282,612518,613455,613939,614278,614291,614642,615257,616717,617876,618327,619122,619133,619933,619936,619947-619962,620088,620569,627768-627771,634001

Modified: myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/util/ResponseUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/util/ResponseUtils.java?rev=634005&r1=634004&r2=634005&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/util/ResponseUtils.java
(original)
+++ myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/util/ResponseUtils.java
Wed Mar  5 11:59:14 2008
@@ -17,8 +17,6 @@
  * limitations under the License.
  */
 
-import org.apache.myfaces.tobago.context.ClientProperties;
-
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.servlet.http.HttpServletResponse;
@@ -40,24 +38,11 @@
     }
   }
 
-  public static void ensureContentTypeHeader(FacesContext facesContext, String charset) {
+  public static void ensureContentTypeHeader(FacesContext facesContext, String contentType)
{
     // TODO PortletRequest
     if (facesContext.getExternalContext().getResponse() instanceof HttpServletResponse) {
       HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
-      response.setContentType(generateContentType(facesContext, charset));
-    }
-  }
-
-  private static String generateContentType(FacesContext facesContext, String charset) {
-    StringBuilder sb = new StringBuilder("text/");
-    ClientProperties clientProperties
-        = ClientProperties.getInstance(facesContext.getViewRoot());
-    sb.append(clientProperties.getContentType());
-    if (charset == null) {
-      charset = "UTF-8";
+      response.setContentType(contentType);
     }
-    sb.append("; charset=");
-    sb.append(charset);
-    return sb.toString();
   }
 }

Modified: myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java?rev=634005&r1=634004&r2=634005&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
(original)
+++ myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
Wed Mar  5 11:59:14 2008
@@ -17,10 +17,10 @@
  * limitations under the License.
  */
 
-import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
-import org.apache.myfaces.tobago.renderkit.html.HtmlStyleMap;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
+import org.apache.myfaces.tobago.renderkit.html.HtmlStyleMap;
+import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.ResponseWriter;
@@ -178,4 +178,21 @@
     writeText(null, property);
   }
 
+  public String getContentTypeWithCharSet() {
+    String contentType = getContentType();
+    if (contentType == null) {
+      contentType = "text/html";
+    }
+    String characterEncoding = getCharacterEncoding();
+    if (characterEncoding == null) {
+      characterEncoding = "UTF-8";
+    }
+
+    StringBuilder builder = new StringBuilder();
+    builder.append(contentType);
+    builder.append("; charset=");
+    builder.append(characterEncoding);
+    return builder.toString();
+
+  }
 }

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java?rev=634005&r1=634004&r2=634005&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
(original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
Wed Mar  5 11:59:14 2008
@@ -24,7 +24,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_CHARSET;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DELAY;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DOCTYPE;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ENCTYPE;
@@ -162,8 +161,8 @@
     String viewId = facesContext.getViewRoot().getViewId();
     String formAction = viewHandler.getActionURL(facesContext, viewId);
     formAction = facesContext.getExternalContext().encodeActionURL(formAction);
-    String charset = (String) page.getAttributes().get(ATTR_CHARSET);
-    ResponseUtils.ensureContentTypeHeader(facesContext, charset);
+    String contentType = writer.getContentTypeWithCharSet();
+    ResponseUtils.ensureContentTypeHeader(facesContext, contentType);
 
     String title = (String) page.getAttributes().get(ATTR_LABEL);
 
@@ -182,13 +181,14 @@
     //if (debugMode) {
     writer.writeJavascript("var TbgHeadStart = new Date();");
     //}
+
     // meta
-    // TODO duplicate; see PageTag.doStartTag()
-//    writer.startElement(HtmlConstants.META, null);
-//    writer.writeAttribute("http-equiv", "Content-Type", null);
-//    writer.writeAttribute(
-//        "content", generateContentType(facesContext, charset), null);
-//    writer.endElement(HtmlConstants.META);
+    // this is needed, because websphere 6.0? ignores the setting of the content type on
the response
+    writer.startElement(HtmlConstants.META, null);
+    writer.writeAttribute("http-equiv", "Content-Type", false);
+    writer.writeAttribute("content", contentType, false);
+    writer.endElement(HtmlConstants.META);
+
     // title
     writer.startElement(HtmlConstants.TITLE, null);
     writer.writeText(title != null ? title : "");



Mime
View raw message