Using AddThis fb:like And g:plusone Attributes With Facelets

By , 1 December 2011

Using AddThis fb:like And g:plusone Attributes With Facelets

Facelets won't parse code like this because of the semicolons:

<a class="addthis_button_google_plusone" g:plusone:size="medium"></a>

The following exception is raised.

javax.faces.view.facelets.FaceletException: Error Parsing /apps/cms/tags/share.xhtml: Error Traced[line: 15] Attribute name "g:plusone" associated with an element type "a" must be followed by the ' = ' character.

CDATA escaping and f:verbatim doesn't fix the problem. The only way around this I could find is using h:output text without escaping the output.

     <!-- escaped because facelets won't parse the g:plusone:size attribute --> 
     <h:outputText escape="false" value="
       &lt;a class=&quot;addthis_button_google_plusone&quot; g:plusone:size=&quot;medium&quot;&gt;&lt;/a&gt;"/>

Notice the input needs to be escaped because facelet files are XML. Ugly. Something like Tomahawk's t:htmlTag would do a better job, but it doesn't support adding arbitrary attributes.

Using AddThis fb:like And g:plusone Attributes With Facelets

About Roger Keays

Using AddThis fb:like And g:plusone Attributes With Facelets

I guess I'd call myself a problem solver. Either that, or I'm some sort of organic machine designed to convert oxygen into carbon dioxide. You could go either way on that. I'm into languages and stuff. I wrote a book. It's okay, I guess. What else? I like reading, swimming, eating, and playing music. Satisfied? Sheesh.

Leave a Comment

Please visit https://rogerkeays.com/using-addthis-fb-like-and-g-plusone-attributes-with-facelets to add your comments.

Comment posted by: regin, 4 years ago

Great! also worked for me!

Comment posted by: Marcelo Luiz Onhate, 4 years ago

 Thanks!! It worked for me!