Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF2.0 custom component development

 
Kumar Gaurav
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy Ranchers,

I am developing a custom component with working environment Jboss 5.1 and JSF2.0 and jsf-facelets-1.1.15.B1. But i am not able to get it working.

Following are the classes and xml entries:


web.xml

<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/frame.taglib.xml</param-value>
</context-param>

frame.taglib.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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://sample.tag/customTags</namespace>
<tag>
<tag-name>iFrame</tag-name>
<tag-name>custom</tag-name>
<component>
<component-type>com.emirates.sds.customComponent.FrameComponent</component-type>
<renderer-type>com.emirates.sds.customComponent.FrameRenderer</renderer-type>
<handler-class>com.emirates.sds.customComponent.FrameHandler</handler-class>
</component>
</tag>
</facelet-taglib>

and java classes


import javax.faces.component.UIComponentBase;

public class FrameComponent extends UIComponentBase{

@Override
public String getFamily() {
return "iFrame";
}

@Override
public String getRendererType() {
return "javax.faces.Frame";
}

}


import javax.faces.view.facelets.ComponentConfig;
import javax.faces.view.facelets.ComponentHandler;

public class FrameHandler extends ComponentHandler{

public FrameHandler(ComponentConfig config) {
super(config);
}
// @Override
// protected MetaRuleset createMetaRuleset(Class type) {
// return super.createMetaRuleset(type).alias("class", "styleClass");
// }
}

import java.io.IOException;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.render.FacesRenderer;
import javax.faces.render.Renderer;
@FacesRenderer(componentFamily="UIComponentBase",rendererType="javax.faces.Frame")
public class FrameRenderer extends Renderer {

@Override
public void encodeBegin(FacesContext context,UIComponent component) throws IOException {

ResponseWriter writer = context.getResponseWriter();

writer.startElement("iframe", null);
writer.writeAttribute("src", component.getAttributes().get("src"), "src");
writer.writeAttribute("style", component.getAttributes().get("style"), "style");
writer.writeAttribute("frameborder", component.getAttributes().get("frameborder"), "frameborder");
writer.writeAttribute("scrolling", component.getAttributes().get("scrolling"), "scrolling");
}

@Override
public void encodeEnd(FacesContext context,UIComponent component) throws IOException {
ResponseWriter writer = context.getResponseWriter();
writer.endElement("iframe");
}

}
Also there is no entry in faces-config.xml

But whenever i am trying to load a page where this component is used i am getting error :
org.xml.sax.SAXParseException: Document root element "facelet-taglib", must match DOCTYPE root "null".

please help me out.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic