Initializing gadget state from robot

0 views
Skip to first unread message

Chris Searle

unread,
Oct 18, 2009, 3:20:50 PM10/18/09
to google-...@googlegroups.com
If you have a robot add a gadget to a wave (adding a document.Gadget
to the blip document) - is there a way to initialize the state of the
gadget? For example - if the robot has found enough information in the
blip text itself - it would be nice to just use it instead of
presenting the user with the form that is used when no state is present.

RoboPhred

unread,
Oct 18, 2009, 3:56:55 PM10/18/09
to Google Wave API
You need to get the Gadget entry from the gadget you added. Once you
do this, you can use element.setField(key, value) to control its
state. I'm not sure how to go about getting the gadget object for a
newly added gadget (gadget insert/append have no return types).
Perhaps you can go back and try something like GadgetView.getGadgets
or getGadget("url") to find it again.

Peter Svedberg

unread,
Oct 18, 2009, 3:58:29 PM10/18/09
to Google Wave API
Chris,

In the java api gadget.setField(key, value) does the trick. You can
then read the field with wave.State().get(key) in the gadget.

see http://wave-robot-java-client.googlecode.com/svn/trunk/doc/com/google/wave/api/Gadget.html
and http://code.google.com/apis/wave/extensions/gadgets/reference.html

-Peter

Chris Searle

unread,
Oct 18, 2009, 4:12:29 PM10/18/09
to google-...@googlegroups.com

On 18. okt.. 2009, at 21.56, RoboPhred wrote:

>
> You need to get the Gadget entry from the gadget you added. Once you
> do this, you can use element.setField(key, value) to control its
> state. I'm not sure how to go about getting the gadget object for a
> newly added gadget (gadget insert/append have no return types).
> Perhaps you can go back and try something like GadgetView.getGadgets
> or getGadget("url") to find it again.

Ah. Looks interesting. This would allow me to replace my python code
with a static XML file (would have to move the code - a urlfetch that
retrieves json - to the gadget - but that's not too hard).

I'll look into this.

Chris Searle

unread,
Oct 19, 2009, 6:34:16 AM10/19/09
to Google Wave API
> > You need to get the Gadget entry from the gadget you added.  Once you
> > do this, you can use element.setField(key, value) to control its
> > state.  I'm not sure how to go about getting the gadget object for a
> > newly added gadget (gadget insert/append have no return types).
> > Perhaps you can go back and try something like GadgetView.getGadgets
> > or getGadget("url") to find it again.

Here's what I'm doing:

gadget = document.Gadget(gadgetUrl)
doc.InsertElement(m.start(0), gadget)

Now - from http://wave-robot-python-client.googlecode.com/svn/trunk/pydocs/waveapi.document.Gadget-class.html
I wonder - can I not just call:

gadget.SubmitDelta()

after adding it to the doc? Not that I can see what format it should
be in yet ;)
Reply all
Reply to author
Forward
0 new messages