-
Notifications
You must be signed in to change notification settings - Fork 298
The Facebook library contains wicket components and behaviors to use the Facebook social plugins with wicket.
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>
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.
...
final Model<String> url = Model.of("http://wicketstuff.org/");
final Comments comments = new Comments("comments", url);
add(comments);
...
...
<div wicket:id="comments"></div>
...
...
// 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.
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
Meta tags for facebook can be set directly at the FacebookSkd component.
final FacebookSdk sdk = new FacebookSdk("fb-root");
sdk.setOgProperty("title", "some title");
- wicket-facebook
- wicket-facebook-examples
<dependency>
<groupId>org.wicketstuff</groupId>
<artifactId>wicket-facebook</artifactId>
<version>6.13.0</version>
</dependency>
<repository>
<id>wicketstuff-core-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
Apache 2.0.