Created
June 22, 2011 14:40
-
-
Save minichate/1040232 to your computer and use it in GitHub Desktop.
GWT GSFN Integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FancyWidget extends Composite { | |
public FancyWidget() { | |
gsfnUpdate(); | |
ScriptElement el = Document.get().createScriptElement(); | |
el.setLang("javascript"); | |
el.setSrc("http://api.getsatisfaction.com/products/67315/topics.json?style=update&callback=gsUpdate&limit=5&product=sheepdoginc_gtrax&sort=last_active_at"); | |
HeadElement element = Document.get().getElementsByTagName("head").getItem(0).cast(); | |
element.appendChild(el); | |
// ... | |
} | |
public void recieveUpdateList(JsArray<GSFNUpdateObject> items) { | |
updates.clear(); | |
for (int i = 0; i < items.length(); i++) { | |
GSFNUpdateObject item = items.get(i); | |
updates.add(new GSFNUpdateWidget(item)); | |
} | |
} | |
public native void gsfnUpdate() /*-{ | |
var reference = this; | |
$wnd.gsUpdate = function(items) { | |
[email protected]::recieveUpdateList(Lcom/google/gwt/core/client/JsArray;)(items.data); | |
} | |
}-*/; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.gwt.core.client.JavaScriptObject; | |
public class GSFNUpdateObject extends JavaScriptObject { | |
protected GSFNUpdateObject() {} | |
public final native String getDate() /*-{ | |
return this.created_at; | |
}-*/; | |
public final native String getTitle() /*-{ | |
return this.subject; | |
}-*/; | |
public final native String getContent() /*-{ | |
return this.content; | |
}-*/; | |
public final native String getLink() /*-{ | |
return this.at_sfn; | |
}-*/; | |
public final native String getAuthorName() /*-{ | |
return this.author.name; | |
}-*/; | |
public final native String getAuthorAvatar() /*-{ | |
return this.author.avatar_url_medium; | |
}-*/; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment