Skip to content
martin-g edited this page Jan 6, 2012 · 3 revisions

Facebook Project

The Facebook library contains wicket components and behaviors to use the Facebook social plugins with wicket.

Quick Overview

If you want to use social plugins or behaviors you have to add the FacebookSdk to your page. Otherwise you will get a MissingFacebookRootException.

public class MySocialPage extends WebPage
{
    public MySocialPage()
    {
         add(new FacebookSdk("fbRoot"));

         final IModel<String> url = Model.of("http://wicketstuff.org");
         add(new LikeButton("likeButton", url));
    }
}
...
<!-- The Facebook SDK should be the first component in your markup -->
<body>
    <div id="fb-root" wicket:id="fbRoot"></div>

    <div wicket:id="likeButton"></div>

Social Plugins

You can find the full list of social plugins on the Facebook developers site: https://developers.facebook.com/docs/plugins/

This library contains the following:

  • Activity Feed
  • Comments
  • Facepile
  • Like Box
  • Like Button
  • Live Stream
  • Login Button
  • Recommendations
  • Send Button

These components can be used like normal wicket components. It is recommended to use a div for the markup. The components should contain the major attributes documented on developers.facebook.com. It is possible to set the properties in the markup as well. They just get overridden if the property is set in at the java component too.

Comments Example

...
		final Model<String> url = Model.of("http://wicketstuff.org/");
		final Comments comments = new Comments("comments", url);
		add(comments);
...
...
       <div wicket:id="comments"></div>
...

Login Button Example

...
                // add your app id to the sdk
		add(new FacebookSdk("fb-root", "your_app_id"));
		final LoginButton button = new LoginButton("loginButton", FacebookPermission.user_about_me, FacebookPermission.user_checkins);
		button.setShowFaces(true);
		
		add(button);
...
...
       <div wicket:id="loginButton" data-width="300"></div>
...

There won't be any feedback by the login button itself weather the user logged in or not. There is a behavior required to recognize a login.

Event Behaviors

https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/ The library contains behaviors for the following events:

  • auth.login
  • auth.authResponseChange
  • auth.statusChange
  • auth.logout
  • auth.prompt
  • xfbml.render
  • edge.create
  • edge.remove
  • comment.create
  • comment.remove

OpenGraph Meta Tags

Meta tags for facebook can be set directly at the FacebookSkd component.

		final FacebookSdk sdk = new FacebookSdk("fb-root");
		sdk.setOgProperty("title", "some title");

Maven Artifacts

  • wicket-facebook
  • wicket-facebook-examples

Documentation

Maven Stable

There is no maven stable build yet.

Maven Development

<dependency>
    <groupId>org.wicketstuff</groupId>
    <artifactId>wicket-facebook</artifactId>
    <version>1.5-SNAPSHOT</version>
</dependency>

<repository>
	<id>wicketstuff-core-snapshots</id>
	<url>https://oss.sonatype.org/content/repositories/snapshots</url>
	<snapshots>
		<enabled>true</enabled>
	</snapshots>		
</repository>

License

Apache 2.0.

Author

Till Freier

Clone this wiki locally