dcorking / google-wave-resources

Automatically exported from code.google.com/p/google-wave-resources
0 stars 0 forks source link

Unable to use setProperty to update gadget state #679

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi.
I'm trying to update the state of a gadget via a Java robot. But it does
not seem to respond. 

I'm using the following code, and I can see the state changed event in my
blip. But I cannot overwrite the value of the gadget. 
  @Override
    public void onGadgetStateChanged(GadgetStateChangedEvent event) {
      Blip blip = event.getBlip();
      Gadget gadget = (Gadget) blip.getElements().get(event.getIndex());
     String count =  gadget.getProperty("count");

     blip.append("State changed changed " + count);
     gadget.setProperty("count", "56");
  }   

The output JSON is:

com.google.wave.api.AbstractRobot serializeOperations: Outgoing operations:
[{"method":"robot.notifyCapabilitiesHash","id":"op3","params":{"capabilitiesHash
":"ffffff706c4aed5f"}},{"method":"document.modify","id":"op4","params":{"waveId"
:"googlewave.com!w+_YMMpvzfD","waveletId":"googlewave.com!conv+root","blipId":"b
+Cza_orZkHF","modifyAction":{"modifyHow":"INSERT_AFTER","values":["State
changed changed 5"],"elements":[null],"useMarkup":false}}}]

Original issue reported on code.google.com by dgraver...@gmail.com on 12 Mar 2010 at 7:43

GoogleCodeExporter commented 9 years ago

Original comment by pamela.fox on 31 Mar 2010 at 11:52

GoogleCodeExporter commented 9 years ago
Thanks, this is a bug. You can't use Element.setProperty method to update 
element 
properties. At the moment, you have to use BlipContentRefs.updateElement(). For 
example:

blip.first(ElementType.GADGET).updateElement(ImmutableMap.of("key", 
"newvalue")); 

Original comment by joe.gregorio@gmail.com on 8 Apr 2010 at 12:29