NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
Kuba78
Joined: 06 Mar 2011 Posts: 3
|
Posted: Sun Mar 06, 2011 11:48 pm Post subject: Problem with custom JSF 2.0 component [duplicated] |
|
|
Hi,
I'm using NetBeans 6.9.1. I created custom JSF 2.0 component:
| Code: | import java.io.IOException;
import javax.faces.component.FacesComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@FacesComponent(value = "mycustom")
public class TestComponent extends UIComponentBase{
@Override
public String getFamily() {
return "custom";
}
@Override
public void encodeEnd(FacesContext context) throws IOException {
ResponseWriter responseWriter = context.getResponseWriter();
responseWriter.startElement("div", null);
responseWriter.writeAttribute("id",getClientId(context),"id");
responseWriter.writeAttribute("name", getClientId(context),"clientId");
responseWriter.write("My custom DIV!");
responseWriter.endElement("div");
}
} |
Taglib for this:
| Code: | <facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
version="2.0">
<namespace>http://javaspotlight.blogspot.com/custom-taglib</namespace>
<tag-name>custom</tag-name>
<component>
<component-type>mycustom</component-type>
</component>
</tag>
</facelet-taglib> |
In my web.xml is :
| Code: | <context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/custom-taglib.xml</param-value>
</context-param> |
On the xhtml page I hev following code:
| Code: | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:fc="http://java.sun.com/jsf/composite/fusionCharts"
xmlns:cu="http://javaspotlight.blogspot.com/custom-taglib">
<h:head>
<title>Fusion Charts free Demo</title>
</h:head>
<h:body>
<h:form id="appForm">
<cu:custom id="customId" />
</h:form>
</h:body>
</html> |
But i get an exception "No library found for this namespace" in red underlinded namespace | Code: | | xmlns:cu="http://javaspotlight.blogspot.com/custom-taglib" | What is a problem ? |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|