Search code examples
facebookgwtgxtfacebook-share

adding facebook share button in gwt application


I have been working with gwt and gxt since around few months,

I am working on a web site which needs to interact with social media web site like facebook,

I am trying to add fcebook share button in my web site , i tried below way -

I tried using HTML -

    HTML facebookButton = new HTML();
                    facebookButton.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

facebookButton.setHTML("<div class=\"fb-share-button\" data-href=\"https://developers.facebook.com/docs/plugins/\" data-layout=\"button\" data-size=\"small\" data-mobile-iframe=\"true\"><a class=\"fb-xfbml-parse-ignore\" target=\"_blank\" href=\"https://www.facebook.com/sharer/......src=sdkpreparse\"> <img src=\"img/social/facebook.png\"  > </a></div>");

But it does nothing -

tab.getUrlHeader() - this what i want to share

i searched across , but could not find anything .

is it possible to create such button in gwt/gxt by any way ..?

any help is appreciated


Solution

  • facebookButton.setHTML("<div class=\"fb-share-button\" data-href=\"https://developers.facebook.com/docs/plugins/\" data-layout=\"button\" data-size=\"small\" data-mobile-iframe=\"true\"><a class=\"fb-xfbml-parse-ignore\" target=\"_blank\" href=\"https://www.facebook.com/sharer/......src=sdkpreparse\"> <img src=\"img/social/facebook.png\"  > </a></div>");
    

    i think this what you copied from facebook share button -

    This is correct , can't understand why this is not working for you.

    You can try the iFrame approach. It is simple and easy.

    I guess you have already created the facebook APP id from your developer account.

    go to this page -

    https://developers.facebook.com/docs/plugins/share-button
    

    enter image description here

    then enter the url you want to share -

    URL to share

    also choose the layout and the button size -

    Layout- Button Size-

    Then click on Get Code - You will get the pop up.

    In this pop up go to iframe tab - and copy the iframe element.

    Then you can set this in your Html Label in GWT like this.

    facebookButton.setHTML("<iframe src=\"https://www.facebook.com/plugins/share_button.php?href=......");
    

    Let me know if it works