Create your own polished presentation in minutes. Just describe what you need.
Free to try, no credit card requiredGWT
Google Wave
Gadgets API
Wave Gadget
=
Wave Gadgets API
Gadgets API
+
XML
XML
state callback
state delta
CSS
CSS
HTML
HTML
state:
state:
vote-douwe@google.com | 1
JS
State Delta
function onClick() {
wave.getState().submitValue('vote-' wave.getViewer().getId(), -1);
}
State Callback
wave.setStateCallback(update);
function update() {
var keys = wave.getState().getKeys();
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (key.match('^vote-')) {
total += parseInt(wave.getState().get(key));
count++;
}
}
document.getElementById('total').innerHTML = total;
}
Mini Webpage
+
Shared State
Collaborative Web App
=
import org.cobogw.gwt.waveapi.gadget.client.StateUpdateEvent;
import org.cobogw.gwt.waveapi.gadget.client.StateUpdateEventHandler;
import org.cobogw.gwt.waveapi.gadget.client.WaveGadget;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.gadgets.client.Gadget;
import com.google.gwt.gadgets.client.UserPreferences;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
@Gadget.ModulePrefs(title = "PlusOne")
public class SimpleCounter extends WaveGadget<UserPreferences> {
private final Label counterLabel = new Label();
private final Button incrementButton = new Button("+1");
private final Button decrementButton = new Button("-1");
@Override
protected void init() {
// Event handlers for increment and decrement buttons
// First they update the local counter's value to the new value
// and then they store the new value in wave's shared state
incrementButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String viewer = getWave().getViewer().getId();
getWave().getState().submitValue(viewer, '1');
}
});
decrementButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String viewer = getWave().getViewer().getId();
getWave().getState().submitValue(viewer, '1');
}
});
// Adding the ui elements to the root panel
RootPanel.get().add(counterLabel);
RootPanel.get().add(incrementButton);
RootPanel.get().add(decrementButton);
getWave().addStateUpdateEventHandler(new StateUpdateEventHandler() {
public void onUpdate(StateUpdateEvent event) {
int total = 0;
JsArrayString keys = getWave().getState().getKeys();
for (int i = 0; i < keys.length(); i++) {
String key = keys.get(i);
String value = getWave().get(key);
total += (int) value;
}
counterLabel.setText(total);
}
});
}
}
Create your own polished presentation in minutes. Just describe what you need.
Free to try, no credit card required