Hi GWT Gurus,

  I have a pretty fundamental question about how to design the server-side 
of my system using RequestFactory. I'm sure I'm missing something pretty 
obvious, so I apologize in advance for the stupidity of the question.

  I have a server side entity (using Objectify for persistence), 

  @Entity
  public class Foo {

    @Id
    private  Long id;

    private String name;
    private int accumulator;
    private List<Bar> bars = new ArrayList<Bar>();

    public String getName() {
      return name;
    }

    public void setName(String name) {
      this.name = name;
    }

    public int getAccumulator() {
      return accumulator;
    }
 
    public void setAccumulator(int accumulator) {
      this.accumulator = accumulator;
    }

    public List<Bar> getBars() {
      return new ArrayList<Bar>(bars);
    }

    public void setBars(List<Bar> bars) {
      this.bars = new ArrayList<Bar>(bars);
    }
  }

 @Embed
  public class Bar {
    private String baz;

    public String getBaz() {
      return baz;
    }

    public void setBaz(String baz) {
      this.baz = baz;
    }
  }

And then the shared interfaces,

  @ProxyFor(value=Foo.class, locator=FooLocator.class)
  public interface FooProxy extends EntityProxy {
    String getName();
    void setName(String name);
    int getAccumulator();
    void setAccumulator(int accumulator);
    List<Bar> getBars();
    setBars(List<Bar> bars);
 }

  @ProxyFor(value=Bar.class)
  public interface BarProxy extends ValueProxy {
    String getBaz();
    void setBaz(String baz);
 }

So far, so good. The problem I have is that when the client modifies the 
entity, when processing that action on the server side I need to be able to 
see what the user has changed and "do things" based on what the user has 
changed. E.g. if the stored list "bars" has been modified in the meantime, 
I need to merge the users changes; I might want to ensure that the 
accumulator only goes up -- that the user cannot set it to a value below 
the value stored on the server side. Essentially, I want the 'stored' 
version of the object and the 'modified' version of the object so I can 
write code that merges the changes, applies any logic I might need, and 
saves the object.

Any help on how to structure my code to allow this, would be much 
appreciated.

Kind regards,
Rich

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to