I'm trying to use the cursor with Objectify and the Google App Engine to return a subset of the data and the cursor so that I can get more data when the user is ready. I found an example here that looks exactly the way I need it, but I don't know how to return the final list plus cursor. Here is the code I have:
@ApiMethod(name = "listIconThemeCursor") //https://code.google.com/p/objectify-appengine/wiki/Queries#Cursors public CollectionResponse<IconTheme> listIconThemeCursor(@Named("cursor") String cursorStr) { Query<IconTheme> query = ofy().load().type(IconTheme.class).limit(10); if (cursorStr != null ) { query.startAt(Cursor.fromWebSafeString(cursorStr)); } List<IconTheme> result = new ArrayList<IconTheme>(); int count = 0; QueryResultIterator<IconTheme> iterator = query.iterator(); while (iterator.hasNext()) { IconTheme theme = iterator.next(); result.add(theme); count++; } Cursor cursor = iterator.getCursor(); String encodeCursor = cursor.toWebSafeString(); return serial(tClass, result, encodeCursor); }
Note that this was changed from the previous endpoint at which I was returning CollectionResponse for ALL data. My data set is large enough that it is no longer practical. Basically, I donβt know what was in the user function 'serial (tClass, result, encodeCursor), which allows it to be returned to the user.
Here is another example, but it also does not answer my question.
source share