Just a couple quick notes to round out the week and serve as placeholders for future entries. I’m using AppEngine for Java with JDO. I’ve modeled a few foreign key relationships (unowned per Google parlance) and have been saving things to the DataStore in production with success so far.
- Use pm.detachCopy() to return objects back to the client. You don’t have to use detachable=”true” in the @PersistenceCapable annotation in order to use pm.detachCopy(). In fact, I couldn’t get it to work with detachable=”true”.
- Use pm.detachCopyAll() and create a new collection to return query result collections back to the client. Will post sample code soon.
- Use Adapter4AppEngine or other technique to enable use of Key fields in objects exchanged with GWT as I blogged a couple days ago.
- Create Keys on the server because GWT doesn’t know what KeyFactory is. To create relationships, your services (action handlers in gwt-dispatch) should accept as arguments the IDs of related objects (or the objects themselves) and then pass the IDs to KeyFactory in the service or action handler to create actual keys.
Upcoming topics for GWT:
- How to create a centered “Loading…” popup panel for actions in progress.
- A technique for navigating to new pages with gwt-presenter by swapping out DIVs.