Re: RequestFactory List of Entities property

2011-10-18 Thread 007design
Thank you so much for your reply.  I modified the request like so:
requestFactory.formRequest().findForm(1).with(fieldsList).fire(...
but now I get an UnexectedException with this message:
Could not determine getter for property value on type Field
Thanks again.


On Oct 17, 11:20 pm, Aidan O'Kelly aida...@gmail.com wrote:
 When you find(), or return an object from other method through
 RequestFactory on the client-side, relationships, such as a ListMyProxy
 need to be explicitly retrieved, using syntax like:

  requestFactory.formRequest().findForm(1).with('fieldList).fire(...

 http://code.google.com/webtoolkit/doc/latest/DevGuideRequestFactory.h...







 On Tue, Oct 18, 2011 at 3:52 AM, 007design 0...@007design.com wrote:
  I'm trying to understand RequestFactory but having quite a difficult
  time.  First, one note: I'm using ORMLite for persistence, I found it
  easier and simpler to learn than Hibernate so I'm hoping I can
  continue to use it.  Those are the @Database annotations in example
  below.  I've boiled down my application to a smaller amount of code.
  I'm really hoping someone can take a quick look at it and tell me what
  I'm doing wrong.  When I try and load the application in the browser I
  get a NullPointerException on response.getFieldsList().  I'm guessing
  that after the Form object is fetched from the database the
  connection is closed or something so calling getFieldsList() doesn't
  work because the method gets more data from the database.

  public class FormBuilder implements EntryPoint {
         public void onModuleLoad() {
                 final Label label = new Label();
                 RootPanel.get(labelContainer).add(label);

                 final EventBus eventBus = new SimpleEventBus();
                 EntityRequestFactory requestFactory =
  GWT.create(EntityRequestFactory.class);
                 requestFactory.initialize(eventBus);

                 requestFactory.formRequest().findForm(1).fire(new
  ReceiverFormProxy() {
                         @Override
                         public void onSuccess(FormProxy response) {
                                 for (FieldProxy field :
  response.getFieldsList()) {
                                         label.setText(label.getText() +
  field.getName());
                                 }
                         }
                 });
         }
  }

  @DatabaseTable (tableName=forms)
  public class Form {
         public Form() {}

         @DatabaseField (columnName=form_id, generatedId=true)
         private Integer id;
         public void setId(Integer id) { this.id = id; }
         public Integer getId() { return id; }

         public ListField getFieldsList() {
                 return Field.getFieldsList(getId());
         }

         public static Form findForm(Integer id) {
                 // Get form record from database
         }

  }

  public class Field {
         public Field() {}

         @DatabaseField (columnName=field_id, generatedId=true)
         private Integer id;
         public void setId(Integer id) { this.id = id; }
         public Integer getId() { return id; }

         /**
          * The form to which this field is associated
          */
         private Integer formId;
         public void setFormId(Integer formId) { this.formId = formId; }
         public Integer getFormId() { return this.formId; }

         public Form getForm() {
                 return Form.findForm(getFormId());
         }

         public static Field findField(Integer id) {
                 // Get field record from database
         }

         public static ListField getFieldsList(Integer id) {
                 // Get field records for db where formid = id
         }
  }

  @ProxyFor (Form.class)
  public interface FormProxy extends EntityProxy {
         Integer getId();
         ListFieldProxy getFieldsList();
         void setId(Integer id);
         void setTimestamp(Date timestamp);
  }

  @ProxyFor (Field.class)
  public interface FieldProxy extends EntityProxy {
         Integer getFormId();
         Integer getId();
         void setFormId(Integer formId);
         void setId(Integer id);
  }

  @Service (Form.class)
  public interface FormRequest extends RequestContext {
         RequestFormProxy findForm(Integer id);
         InstanceRequestFormProxy, ListFieldProxy getFieldsList();
  }

  @Service (Field.class)
  public interface FieldRequest extends RequestContext {
         RequestFieldProxy findField(Integer id);
         RequestListFieldProxy getFieldsList(Integer formId);
  }

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

-- 
You received this message 

Re: RequestFactory List of Entities property

2011-10-18 Thread 007design
I don't know what the issue was exactly but I seem to have gotten it
to work.  Now my question is if there's a better way to fetch complex
object graphs from the server than having to write:
request.findEntity.with(itemA.itemB.itemC, itemA.itemD.itemC ...)
Is there a more efficient way to do this?
Thanks!

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



Re: RequestFactory List of Entities property

2011-10-18 Thread Aidan O'Kelly
If you are using the Editor framework to edit (or display) the object,
RequestFactoryEditorDriver can build a list of paths based on the tree of
editors.
If your object graph is that complex, the Editor framework is probably worth
looking into!

One thing to note about with(), is it silently ignores paths that don't map
to anything on the server. So watch out for typos if you are building the
paths manually.

On Tue, Oct 18, 2011 at 2:28 PM, 007design 0...@007design.com wrote:

 I don't know what the issue was exactly but I seem to have gotten it
 to work.  Now my question is if there's a better way to fetch complex
 object graphs from the server than having to write:
 request.findEntity.with(itemA.itemB.itemC, itemA.itemD.itemC ...)
 Is there a more efficient way to do this?
 Thanks!

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



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