[ 
https://issues.apache.org/jira/browse/MYFACES-4536?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17771454#comment-17771454
 ] 

Melloware commented on MYFACES-4536:
------------------------------------

I see the difference between your code and PrimeFaces code.  Your code is 
directly calling
{code:java}
_writer.startElement("eval", null); {code}
In PrimeFaces we have a PrimePartialResponseWriter that does this...


{code:java}
@Override    
public void startEval() throws IOException {        
   startMetadataIfNecessary();
   super.startEval();    
} {code}
Then our code when its encoding is calling the Myfaces startEval and endEval() 
directly its not calling start and end element.

 
{code:java}
protected void encodeScripts(PrimeRequestContext requestContext) throws 
IOException {        
List<String> initScripts = requestContext.getInitScriptsToExecute();        
List<String> scripts = requestContext.getScriptsToExecute();
        
if (!initScripts.isEmpty() || !scripts.isEmpty()) {   
         
startEval(); // START EVAL inherited

            for (int i = 0; i < initScripts.size(); i++) {                
getWrapped().write(initScripts.get(i));                getWrapped().write(';'); 
           }
            for (int i = 0; i < scripts.size(); i++) {                
getWrapped().write(scripts.get(i));                
getWrapped().write(';');            }
            
endEval(); // START EVAL inherited     
}    
} {code}

> PartialResponseWriter: Do no wrap the writer
> --------------------------------------------
>
>                 Key: MYFACES-4536
>                 URL: https://issues.apache.org/jira/browse/MYFACES-4536
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: General
>    Affects Versions: 2.2.14, 2.3.10, 2.3-next-M7, 4.0.0-RC2
>            Reporter: Melloware
>            Assignee: Werner Punz
>            Priority: Major
>         Attachments: csp-results.zip, image-2023-10-02-20-33-05-162.png, 
> mojarra-csp-new.txt
>
>
> Per BalusC:
> Since JSF 2.3 the default constructor of {{FacesWrapper}} subclasses has been 
> deprecated in order to force implementors to instead use the constructor 
> taking the wrapped instance (and to raise their awareness), so that logically 
> the inherited {{getWrapped()}} method will be used throughout the 
> implementation instead of the local {{wrapped}} variable. This will ensure 
> that the correct implementation is returned and correct behavior is performed 
> might the {{FacesWrapper}} implementation itself being wrapped by yet another 
> {{FacesWrapper}} implementation further down the chain. Because, when the 
> {{FacesWrapper}} implementation incorrectly/accidentally uses the local 
> {{wrapped}} variable instead of the {{getWrapped()}} method, then that other 
> {{FacesWrapper}} implementation will basically be completely ignored, hereby 
> breaking the decorator pattern.
>  
> PrimeFaces ticket: https://github.com/primefaces/primefaces/issues/9518



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to