myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aurel.sa...@vectorsoftware.ro
Subject Custom renderer
Date Fri, 24 Apr 2009 14:27:52 GMT
Hi,

I want to built a custom render kit for SVG. I put in faces-config.xml the following
<render-kit>
	<render-kit-id>SVG</render-kit-id>
	<renderer>
		<component-family>javax.faces.Command</component-family>
		<renderer-type>rendersvg.Button</renderer-type>
		<renderer-class>rendersvg.CommandButtonTag</renderer-class>
	</renderer>
	others renders
	....
</render-kit>

I use this renderkit in the following jsp:

<?xml version="1.0"?>

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<%@ page contentType="image/svg+xml"%>
<%@ taglib uri="http://java.sun.com/jsf/svg" prefix="g" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
                                                                                       
<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink">
    <style type="text/css">
      rect:hover {fill-opacity:0.3;}
    </style>

    <f:view renderKitId="SVG" >  
        <g:form id="form">
           <g:outputText x="100" y="50" textAnchor="middle" value=".xxx..."
                         style="stroke:black; stroke-width:0.5; fill:none; font-size:32pt;"
/>
....................
        </g:form>
    </f:view>
</svg>

I wrote the renderers (this is one example)
public class ButtonRenderer extends Renderer {
..........
    public void decode(FacesContext context, UIComponent component) {
   ............
    }
    public void encodeBegin(FacesContext context, UIComponent component)      throws IOException
{
..........
    }

    public void encodeEnd(FacesContext context, UIComponent component)
................
    }
}

I wrote the tag clases 
public final class CommandButtonTag extends UIComponentELTag {
..........
    public String getRendererType() {
        return "rendersvg.Button";
    }

    public String getComponentType() {
        return "javax.faces.Command";
    }
..........
}

But when I start tomcat I get
Apr 24, 2009 4:38:21 PM org.apache.myfaces.config.FacesConfigurator configureRenderKits
SEVERE: failed to configure rendersvg.CommandButtonTag
java.lang.ClassCastException: rendersvg.CommandButtonTag
	at org.apache.myfaces.config.FacesConfigurator.configureRenderKits(FacesConfigurator.java:859)
	at org.apache.myfaces.config.FacesConfigurator.configure(FacesConfigurator.java:278)
	at org.apache.myfaces.webapp.AbstractFacesInitializer.buildConfiguration(AbstractFacesInitializer.java:131)
	at org.apache.myfaces.webapp.Jsp21FacesInitializer.initContainerIntegration(Jsp21FacesInitializer.java:64)
	at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:83)
	at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:72)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
	at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
	at org.apache.catalina.core.StandardService.start(StandardService.java:516)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

What do you think I am missing?
Thanks,
Aurel



Mime
View raw message