You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ef...@apache.org on 2007/08/15 22:22:58 UTC

svn commit: r566325 - /myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java

Author: efastl
Date: Wed Aug 15 13:22:57 2007
New Revision: 566325

URL: http://svn.apache.org/viewvc?view=rev&rev=566325
Log:
Fix for TOMAHAWK-1085 encoding issue with PPRPanelGroup

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java?view=diff&rev=566325&r1=566324&r2=566325
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java Wed Aug 15 13:22:57 2007
@@ -36,6 +36,8 @@
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
+import javax.servlet.http.HttpServletRequest;
+
 import java.io.IOException;
 import java.util.*;
 
@@ -197,9 +199,19 @@
 	{
 	    requestMap.put(PPR_INITIALIZED, Boolean.TRUE);
 
+	    String encoding = "UTF-8" ; // Hardcoded default
+	    if(externalContext.getRequest() instanceof HttpServletRequest){
+		HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
+		if(request.getCharacterEncoding() != null)
+		    encoding = request.getCharacterEncoding();
+	    }
+	    
+	    DojoConfig currentConfig = DojoUtils.getDjConfigInstance(facesContext);
+	    currentConfig.setBindEncoding(encoding);
+	    
 	    String javascriptLocation = (String) pprGroup.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
 	    AddResource addResource = AddResourceFactory.getInstance(facesContext);
-	    DojoUtils.addMainInclude(facesContext, pprGroup, javascriptLocation, new DojoConfig());
+	    DojoUtils.addMainInclude(facesContext, pprGroup, javascriptLocation, currentConfig);
 	    DojoUtils.addRequire(facesContext, pprGroup, "dojo.io.*");
 	    DojoUtils.addRequire(facesContext, pprGroup, "dojo.event.*");
 	    addResource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, PPRPanelGroup.class,



Re: svn commit: r566325 - /myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!
> Where does the responseWriter get the encoding from?
> Is that configured?
>   
Like your code, it gets it from
pageContext.getRequest().getCharacterEncoding() (in UIComponentTag),
however, there is no need to do any instanceof and cast if you ask the
ResponseWriter later then.

Ciao,
Mario
> cheers
>
> Ernst
>
> On 8/15/07, Mario Ivankovits <ma...@ops.co.at> wrote:
>   
>> Hi!
>>     
>>> http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java?view=diff&rev=566325&r1=566324&r2=566325
>>>
>>> +         String encoding = "UTF-8" ; // Hardcoded default
>>> +         if(externalContext.getRequest() instanceof HttpServletRequest){
>>> +             HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
>>> +             if(request.getCharacterEncoding() != null)
>>> +                 encoding = request.getCharacterEncoding();
>>> +         }
>>>
>>>       
>> Hmmm .... wouldn't be the correct way to do this to ask the
>> ResponseWriter about the encoding?
>>
>> Something like:
>>
>> String encoding = facesContext.getResponseWriter().getCharacterEncoding();
>>
>>
>>
>> Ciao,
>> Mario
>>
>>
>>     
>
>   


Re: svn commit: r566325 - /myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java

Posted by Ernst Fastl <er...@gmail.com>.
Hi,

Might be an option too. I thought it best to return the client the
encoding he requests. Maybe the responseWriter-encoding
should be used before the hardcoded default.

Where does the responseWriter get the encoding from?
Is that configured?

cheers

Ernst

On 8/15/07, Mario Ivankovits <ma...@ops.co.at> wrote:
> Hi!
> > http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java?view=diff&rev=566325&r1=566324&r2=566325
> >
> > +         String encoding = "UTF-8" ; // Hardcoded default
> > +         if(externalContext.getRequest() instanceof HttpServletRequest){
> > +             HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
> > +             if(request.getCharacterEncoding() != null)
> > +                 encoding = request.getCharacterEncoding();
> > +         }
> >
> Hmmm .... wouldn't be the correct way to do this to ask the
> ResponseWriter about the encoding?
>
> Something like:
>
> String encoding = facesContext.getResponseWriter().getCharacterEncoding();
>
>
>
> Ciao,
> Mario
>
>

Re: svn commit: r566325 - /myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!
> http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ppr/PPRPanelGroupRenderer.java?view=diff&rev=566325&r1=566324&r2=566325
>  
> +	    String encoding = "UTF-8" ; // Hardcoded default
> +	    if(externalContext.getRequest() instanceof HttpServletRequest){
> +		HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
> +		if(request.getCharacterEncoding() != null)
> +		    encoding = request.getCharacterEncoding();
> +	    }
>   
Hmmm .... wouldn't be the correct way to do this to ask the
ResponseWriter about the encoding?

Something like:

String encoding = facesContext.getResponseWriter().getCharacterEncoding();



Ciao,
Mario