Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

JSF2.0 custom component development  RSS feed

 
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!