use of javax.faces.event.ComponentSystemEventListener in project liferay-faces-bridge-ext by liferay.
the class ResourceRendererLiferayImpl method processEvent.
/**
* Since the Mojarra {@link com.sun.faces.renderkit.html_basic.ScriptStyleBaseRenderer} class implements {@link
* ComponentSystemEventListener}, this class must implement that interface too, since this is a wrapper type of
* class. Mojarra uses this method to intercept {@link PostAddToViewEvent} in order to add script and link resources
* to the head (if the target attribute has a value of "head").
*/
@Override
public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
// associated with the specified event as a resource on the view root.
if (wrappedRenderer instanceof ComponentSystemEventListener) {
ComponentSystemEventListener wrappedListener = (ComponentSystemEventListener) wrappedRenderer;
wrappedListener.processEvent(event);
} else {
logger.debug("Wrapped renderer=[{0}] does not implement ComponentSystemEventListener", wrappedRenderer);
}
}
use of javax.faces.event.ComponentSystemEventListener in project liferay-faces-bridge-impl by liferay.
the class ResourcesRenderedInHeadTestBean method preRenderHeadListener.
/**
* This method causes each head resource to render an id attribute containing the resource name or client id if the
* resource name is unavailable. See {@link ResponseWriterResourceIdImpl} and the comments below for more details.
*/
public void preRenderHeadListener(ComponentSystemEvent componentSystemEvent) throws AbortProcessingException {
// Obtain all head resources.
UIComponent uiComponent = componentSystemEvent.getComponent();
List<UIComponent> children = uiComponent.getChildren();
FacesContext facesContext = FacesContext.getCurrentInstance();
UIViewRoot uiViewRoot = facesContext.getViewRoot();
List<UIComponent> componentResources = uiViewRoot.getComponentResources(facesContext, "head");
List<UIComponent> headResources = new ArrayList<UIComponent>(children);
headResources.addAll(componentResources);
// ResponseWriter to an instance of ResponseWriterResourceIdImpl.
for (UIComponent headResource : headResources) {
String rendererType = headResource.getRendererType();
if ((headResource instanceof UIOutput) && (rendererType.equals("javax.faces.resource.Script") || rendererType.equals("javax.faces.resource.Stylesheet"))) {
headResource.subscribeToEvent(PreRenderComponentEvent.class, new ComponentSystemEventListener() {
@Override
public void processEvent(ComponentSystemEvent componentSystemEvent) throws AbortProcessingException {
FacesContext facesContext = FacesContext.getCurrentInstance();
ResponseWriter responseWriter = facesContext.getResponseWriter();
if (!(responseWriter instanceof ResponseWriterResourceIdImpl)) {
facesContext.setResponseWriter(new ResponseWriterResourceIdImpl(responseWriter));
}
}
});
}
}
}
use of javax.faces.event.ComponentSystemEventListener in project liferay-faces-bridge-impl by liferay.
the class ResourceRendererBridgeImpl method processEvent.
/**
* Since the Mojarra {@link com.sun.faces.renderkit.html_basic.ScriptStyleBaseRenderer} class implements {@link
* ComponentSystemEventListener}, this class must implement that interface too, since this is a wrapper type of
* class. Mojarra uses this method to intercept {@link PostAddToViewEvent} in order to add script and link resources
* to the head (if the target attribute has a value of "head").
*/
@Override
public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
// associated with the specified event as a resource on the view root.
if (wrappedRenderer instanceof ComponentSystemEventListener) {
ComponentSystemEventListener wrappedListener = (ComponentSystemEventListener) wrappedRenderer;
wrappedListener.processEvent(event);
} else {
logger.debug("Wrapped renderer=[{0}] does not implement ComponentSystemEventListener", wrappedRenderer);
}
}
use of javax.faces.event.ComponentSystemEventListener in project liferay-faces-bridge-impl by liferay.
the class ResourceRendererImpl method processEvent.
/**
* Since the Mojarra com.sun.faces.renderkit.html_basic.ScriptStyleBaseRenderer class implements {@link
* ComponentSystemEventListener}, this class must implement that interface too, since this is a wrapper type of
* class. Mojarra uses this method to intercept {@link PostAddToViewEvent} in order to add script and link resources
* to the head (if the target attribute has a value of "head").
*/
@Override
public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
// associated with the specified event as a resource on the view root.
if (wrappedRenderer instanceof ComponentSystemEventListener) {
ComponentSystemEventListener wrappedListener = (ComponentSystemEventListener) wrappedRenderer;
wrappedListener.processEvent(event);
} else {
logger.debug("Wrapped renderer=[{0}] does not implement ComponentSystemEventListener", wrappedRenderer);
}
}
use of javax.faces.event.ComponentSystemEventListener in project liferay-faces-alloy by liferay.
the class OutputScriptStylesheetRendererBase method processEvent.
@Override
public void processEvent(ComponentSystemEvent componentSystemEvent) throws AbortProcessingException {
FacesContext facesContext = FacesContext.getCurrentInstance();
Renderer delegateRenderer = getDelegateRenderer(facesContext);
if (delegateRenderer instanceof ComponentSystemEventListener) {
ComponentSystemEventListener delegateComponentSystemEventListener = (ComponentSystemEventListener) delegateRenderer;
delegateComponentSystemEventListener.processEvent(componentSystemEvent);
}
}
Aggregations