The RequestFactory sample apps in GWT 2.1 use JDO and JPA because
these are the Java persistence APIs offered by App Engine; however,
RequestFactory has no dependency on them, and you can use Objectify
instead. RequestFactory won't be able to serialize the Objectify Key
object so you should expose only convenience methods like getParent()
below that know how to map the key to the actual entity. Here's an
example that exposes only RequestFactory-safe methods:
@ProxyFor(ListItem.class)
public interface ListItemProxy extends EntityProxy
{
Long getId();
String getItemText();
void setItemText(String itemText);
void setParent(ItemListProxy editList);
ItemListProxy getParent();
}
@Entity
public class ListItem
{
@Id private Long id;
private String itemText;
@Version
private Integer version;
// Dummy field due to JsonRequestProcessor:1543
transient private ItemList parent;
// Real parent key used by Objectify
@Parent private Key<ItemList> parentKey;
public ListItem()
{
// No-arg constructor required
}
public void setParent(ItemList parent)
{
this.parentKey = new ItemListDao().key(parent);
}
public ItemList getParent()
{
try
{
return new ItemListDao().get(parentKey);
}
catch (EntityNotFoundException e)
{
e.printStackTrace();
}
return null;
}
}
HTH,
/dmc
On Mon, Nov 1, 2010 at 10:14 AM, Tobias <thabermann@gmail.com> wrote:
>
> Hi,
>
> to get accustomed to GAE as well as GWT 2.1, I am working on a pet
> project for managing Recipes. A Recipe has multiple Ingredients, which
> I want to display in a CellTable, each Ingredient having (editable)
> columns for Amount and Type. New Ingredient lines in the table can be
> added with a button, existing ingredients can be removed and reordered
> by buttons (or DnD later).
> So now I am trying to figure out how to wire this up with the Editor
> framework and RequestFactory on the Client-side and the GAE datastore
> and Objectify (or JDO, if that makes it any easier). I created some
> dummy Recipe object with a getIngredients()-list with some dummy
> Ingredients and managed to get the CellTable populated with these by
> the Editor driver automatically.
>
> What I do not understand however is how far this databinding goes? How
> would I implement an "Add Ingredient" button, that would create a new
> empty Ingredient, and would I have to create the CellTable row for
> that manually or would the Editor driver do that for me?
>
> My other question is related to the Server model. RequestFactory seems
> to be tailored to JDO/JPA. Apparently, to enable the Editor framework
> work, my Recipe class needs a getIngredients() method. How should I
> implement this in an Objectify based persistence?
>
> Thank you,
> Tobias
>
> --
> 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+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
>
--
David Chandler
Developer Programs Engineer, Google Web Toolkit
http://googlewebtoolkit.blogspot.com/
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment