use of jakarta.faces.render.FacesBehaviorRenderer in project myfaces by apache.
the class AnnotationConfigurator method handleFacesBehaviorRenderer.
private void handleFacesBehaviorRenderer(FacesConfigImpl facesConfig, Set<Class<?>> classes) {
for (Class<?> clazz : classes) {
FacesBehaviorRenderer facesBehaviorRenderer = (FacesBehaviorRenderer) clazz.getAnnotation(FacesBehaviorRenderer.class);
if (facesBehaviorRenderer != null) {
String renderKitId = facesBehaviorRenderer.renderKitId();
if (log.isLoggable(Level.FINEST)) {
log.finest("addClientBehaviorRenderer(" + renderKitId + ", " + facesBehaviorRenderer.rendererType() + ", " + clazz.getName() + ')');
}
org.apache.myfaces.config.impl.element.RenderKitImpl renderKit = (org.apache.myfaces.config.impl.element.RenderKitImpl) facesConfig.getRenderKit(renderKitId);
if (renderKit == null) {
renderKit = new org.apache.myfaces.config.impl.element.RenderKitImpl();
renderKit.setId(renderKitId);
facesConfig.addRenderKit(renderKit);
}
org.apache.myfaces.config.impl.element.ClientBehaviorRendererImpl cbr = new org.apache.myfaces.config.impl.element.ClientBehaviorRendererImpl();
cbr.setRendererType(facesBehaviorRenderer.rendererType());
cbr.setRendererClass(clazz.getName());
renderKit.addClientBehaviorRenderer(cbr);
}
}
}
use of jakarta.faces.render.FacesBehaviorRenderer in project mojarra by eclipse-ee4j.
the class RenderKitConfigHandler method push.
/**
* @see com.sun.faces.application.annotation.ConfigAnnotationHandler#push(jakarta.faces.context.FacesContext)
*/
@Override
public void push(FacesContext ctx) {
if (annotatedRenderers != null) {
RenderKitFactory rkf = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
for (Map.Entry<Class<?>, Annotation> entry : annotatedRenderers.entrySet()) {
Class<?> rClass = entry.getKey();
if (entry.getValue() instanceof FacesRenderer) {
FacesRenderer ra = (FacesRenderer) entry.getValue();
try {
RenderKit rk = rkf.getRenderKit(ctx, ra.renderKitId());
if (rk == null) {
throw new IllegalStateException("Error processing annotated Renderer " + ra.toString() + " on class " + rClass.getName() + ". Unable to find specified RenderKit.");
}
rk.addRenderer(ra.componentFamily(), ra.rendererType(), (Renderer) rClass.newInstance());
} catch (IllegalStateException | InstantiationException | IllegalAccessException e) {
throw new FacesException(e);
}
} else if (entry.getValue() instanceof FacesBehaviorRenderer) {
FacesBehaviorRenderer bra = (FacesBehaviorRenderer) entry.getValue();
try {
RenderKit rk = rkf.getRenderKit(ctx, bra.renderKitId());
if (rk == null) {
throw new IllegalStateException("Error processing annotated ClientBehaviorRenderer " + bra.toString() + " on class " + rClass.getName() + ". Unable to find specified RenderKit.");
}
rk.addClientBehaviorRenderer(bra.rendererType(), (ClientBehaviorRenderer) rClass.newInstance());
} catch (IllegalStateException | InstantiationException | IllegalAccessException e) {
throw new FacesException(e);
}
}
}
}
}
Aggregations