I created this simple test phaseListener before my original post and it only
works an a postback, not an initial request.  /Put the code in both phases
just in case./  *No Luck*. 

package com.ngsimages.cart.phaselistener;

import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;

import org.apache.myfaces.renderkit.html.util.AddResource;
import org.apache.myfaces.renderkit.html.util.AddResourceFactory;

/**
 * @author mfischer
 *
 */
public class AddResourceListener implements PhaseListener {
        /**
         * 
         */
        private static final long serialVersionUID = -7584339550737064360L;

        @Override
        public void afterPhase(PhaseEvent arg0) {
                AddResource ar = 
AddResourceFactory.getInstance(arg0.getFacesContext());
                ar.addInlineScriptAtPosition(arg0.getFacesContext(),
AddResource.HEADER_BEGIN, "window.open()");
        }
        
        @Override
        public void beforePhase(PhaseEvent arg0) {
                AddResource ar = 
AddResourceFactory.getInstance(arg0.getFacesContext());
                ar.addInlineScriptAtPosition(arg0.getFacesContext(),
AddResource.HEADER_BEGIN, "window.open()");
                
        }
        
        @Override
        public PhaseId getPhaseId() {
                return PhaseId.RENDER_RESPONSE;
        }
}

Shame to have to create a component just to add javascript.

Any other ideas on how to dynamically add a script to the page header?



--
View this message in context: 
http://myfaces.10567.n7.nabble.com/addResource-to-add-CSS-JS-Only-working-on-PostBack-tp121593p121618.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to