Skip to content

Instantly share code, notes, and snippets.

@minichate
Created June 22, 2011 14:40
Show Gist options
  • Save minichate/1040232 to your computer and use it in GitHub Desktop.
Save minichate/1040232 to your computer and use it in GitHub Desktop.
GWT GSFN Integration
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);
}
}-*/;
}
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