myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r909507 - /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java
Date Fri, 12 Feb 2010 17:31:30 GMT
Author: lu4242
Date: Fri Feb 12 17:31:29 2010
New Revision: 909507

URL: http://svn.apache.org/viewvc?rev=909507&view=rev
Log:
MYFACES-2551 Set charset=iso-8859-1 using <f:view> in facelets page makes current page
not being rendered

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java?rev=909507&r1=909506&r2=909507&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java
Fri Feb 12 17:31:29 2010
@@ -97,9 +97,33 @@
                 String v = this.renderKitId.getValue(ctx);
                 root.setRenderKitId(v);
             }
+            String encodingValue = null;
             if (this.contentType != null)
             {
+                // This value is read as rfc2616 section 3.7 Media Types.
+                // We should check and extract the param "charset" and assing
+                // it as encoding for this page.
                 String v = this.contentType.getValue(ctx);
+                if (v != null)
+                {
+                    int j = v.indexOf(';');
+                    if (j >= 0)
+                    {
+                        int i = v.indexOf("charset",j);
+                        if (i >= 0)
+                        {
+                            i = v.indexOf('=',i)+1;
+                            if (v.length() > i)
+                            {
+                                encodingValue = v.substring(i);
+                            }
+                            // Substract charset from encoding, it will be added 
+                            // later on FaceletViewDeclarationLanguage.createResponseWriter
+                            // by calling response.setContentType
+                            v = v.substring(0 , j);
+                        }
+                    }
+                }
                 ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.ContentType",
v);
             }
             if (this.encoding != null)
@@ -107,6 +131,10 @@
                 String v = this.encoding.getValue(ctx);
                 ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.Encoding",
v);
             }
+            else if (encodingValue != null)
+            {
+                ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.Encoding",
encodingValue);
+            }
             if (this.beforePhase != null)
             {
                 MethodExpression m = this.beforePhase.getMethodExpression(ctx, null, LISTENER_SIG);



Mime
View raw message