Sunday, November 8, 2009

Creating Google gadgets with GWT - tutorial part 2

You should read part one before you continue here.


First lesson learned: you cannot get the HOST name of you gadget


String hostHost = Location.getHost().toLowerCase();
String hostName = Location.getHostName();





So I will be using URL parameters to set up my widget:


String gadget = Location.getParameter("gadget"); 








facebook4GWT API:


http://code.google.com/p/facebook4gwt/downloads/list












Creating Facebook gadgets in Google OpenSocial container does not work too well since you register the page on which Facebook app lives and in our case it is a Google server (e.g. 1.blogger.gmodules.com)





Facebook.init("7e52b37f9cc369XYZ1232");

Facebook.addLoginHandler(new FacebookLoginHandler()
{
    public void loginStatusChanged(FacebookLoginEvent event)
    {
if (event.isLoggedIn())
{
    facebookStatus.setText("Logged in");

    Facebook.APIClient().users_getLoggedInUser(new AsyncCallback()
    {
public void onSuccess(FacebookUser result)
{
    userName.setText(result.getName());
    userImage.setUrl(result.getPic());
    facebookStatus.setText(result.getStatus());


Solution for all this problems?

Use iFrame, I will investigate the best solutions in part 3 soon.