I think, therefore I blog

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

Roger Keays is an artist, an engineer, and a student of life. Since he left Australia in 2009, he has been living as a digital nomad in over 40 different countries around the world. Roger is addicted to surfing. His other interests are music, psychology, languages, and finding good food. Click here to subscribe to his weekly blog, or stalk him on Facebook and Twitter.

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, 2 years ago

Great! also worked for me!

Comment posted by: Marcelo Luiz Onhate, 3 years ago

 Thanks!! It worked for me!

Join Over 1000 Subscribers

I write every Sunday about travel, psychology, and technology. Thousands of people just like you have already subscribed—and for good reason. It'll change your life. And it's free :)

Read a Good Book

“A spellbinding true story of love, passion and adventure. One can’t help but be swept away by 100% Love Guaranteed.” —Dr Tammie Matson, author of Elephant Dance.

Chat For A While

Your Vote Matters

Which animal will take over when humans go extinct?