Facebook and JSF social plugins

I need to integrate Facebook social plugins into the JSF app. This recommends adding the fbml namespace to the xhtml file that it displayed in the response.

I have an XHTML file:

<!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:ui="http://java.sun.com/jsf/facelets" ... xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://ogp.me/ns#"> 

But the fb and og namespace will not be displayed in the displayed source, but only in the XHTML namespace. How can I get these namespaces written in response?

There is this problem: https://stackoverflow.com/questions/5199176/include-facebook-social-plugins-in-a-jsf2-page , but she has not answered yet.

The only idea I got is to make an iframe and include a simple XHTML file (not Facelet, just pure XHTML), but it seems dirty.

I hope someone has a better solution.


Additional information: I use facelets and seam 2.2.

I assume that ResponseWriter.startDocument() prints a Doctype and <html> element, is that correct? Or is it just another UIComponent that displays the <html> element? It would be nice if I could implement a custom ResponseWriter and override startDocument() and set my user writer by default.

This leads me to two questions:

  • Which class should I override, so I donโ€™t need to implement every abstract ResponseWriter method?
  • How can I tell my application to use my custom ResponseWriter ?

Or implements a custom component that makes the <html> job? I'm asking about this because facelets seem to display the <html> tag on its own, and there seems to be no way to change this, so I came up with overriding ResponseWriter .

0
source share
1 answer

I found out that I just need to write a custom component:

 public class CvHTML extends UIOutput { @Override public void encodeBegin(final FacesContext context) throws IOException { final ResponseWriter writer = context.getResponseWriter(); writer.startDocument(); writer.startElement("HTML", null); writer.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml", null); writer.writeAttribute("xmlns:fb", "http://www.facebook.com/2008/fbml", null); writer.writeAttribute("xmlns:og", "http://ogp.me/ns#", null); } @Override public void encodeEnd(final FacesContext context) throws IOException { final ResponseWriter writer = context.getResponseWriter(); writer.endElement("HTML"); writer.endDocument(); } } 

and a call in the main template:

 <cv:html xmlns="http://www.w3.org/1999/xhtml" lang="en" xmlns:s="http://jboss.com/products/seam/taglib" .... xmlns:cv="http://your.name.space/foo"> 
+1
source

All Articles