It's possible to set a null field to a non-null value by making a Leaf
CompositeEditor.  I'll update the DynaTableRf sample with something
better than this, but I think it demonstrates the point.  The
assumption is that PersonProxy.getManager() returns null in the
default dataset.


public class ManagerSelector extends Composite implements
    CompositeEditor<PersonProxy, PersonProxy, NameLabel>,
    LeafValueEditor<PersonProxy> {

  private EditorChain<PersonProxy, NameLabel> chain;
  private NameLabel nameLabel = new NameLabel(new SimpleEventBus());
  private PersonProxy manager;

  public ManagerSelector() {
    FlowPanel fp = new FlowPanel();
    Button b = new Button("Choose randomly");

    b.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        DynaTableRequestFactory rf = DynaTableRf.getRequestFactory();

        int i = new Random().nextInt(100);
        rf.schoolCalendarRequest().getPeople(i, 1).to(
            new Receiver<List<PersonProxy>>() {
              @Override
              public void onSuccess(List<PersonProxy> response) {
                assert response.size() == 1;
                setValue(response.get(0));
              }
            }).fire();
      }
    });

    fp.add(b);
    fp.add(nameLabel);
    initWidget(fp);
  }

  public void flush() {
  }

  public String getPathElement(NameLabel subEditor) {
    return "";
  }

  public PersonProxy getValue() {
    return manager;
  }

  public void onPropertyChange(String... paths) {
  }

  public void setDelegate(EditorDelegate<PersonProxy> delegate) {
  }

  public void setEditorChain(EditorChain<PersonProxy, NameLabel> chain) {
    this.chain = chain;
  }

  public void setValue(PersonProxy value) {
    this.manager = value;

    if (manager != null) {
      chain.attach(manager, nameLabel);
    }
  }


-- 
Bob Vawter
Google Web Toolkit Team

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to