Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing/Searching AsyncDataProvider with Objectify / Google App Engine
    primarykey
    data
    text
    <p>I currently have an application which uses the activities/places and an AsyncDataProvider.</p> <p>Right now, everytime the activity loads up - it uses the request factory to retrieve the data (currently not a lot but will get very large coming up here soon) and passes it to the View to update the DataGrid. Before it is updated it is filtered based on a search box.</p> <p>Right now - I have implemented updating the DataGrid as follows: (this code isn't the prettiest)</p> <pre><code>private void updateData() { final AsyncDataProvider&lt;EquipmentTypeProxy&gt; provider = new AsyncDataProvider&lt;EquipmentTypeProxy&gt;() { @Override protected void onRangeChanged(HasData&lt;EquipmentTypeProxy&gt; display) { int start = display.getVisibleRange().getStart(); int end = start + display.getVisibleRange().getLength(); final List&lt;EquipmentTypeProxy&gt; subList = getSubList(start, end); end = (end &gt;= subList.size()) ? subList.size() : end; if (subList.size() &lt; DATAGRID_PAGE_SIZE) { updateRowCount(subList.size(), true); } else { updateRowCount(data.size(), true); } updateRowData(start, subList); } private List&lt;EquipmentTypeProxy&gt; getSubList(int start, int end) { final List&lt;EquipmentTypeProxy&gt; filteredEquipment; if (searchString == null || searchString.equals("")) { if (data.isEmpty() == false &amp;&amp; data.size() &gt; (end - start)) { filteredEquipment = data.subList(start, end); } else { filteredEquipment = data; } } else { filteredEquipment = new ArrayList&lt;EquipmentTypeProxy&gt;(); for (final EquipmentTypeProxy equipmentType : data) { if (equipmentType.getName().contains(searchString)) { filteredEquipment.add(equipmentType); } } } return filteredEquipment; } }; provider.addDataDisplay(dataGrid); } </code></pre> <p>Ultimately - what I would like to do is only load up the necessary data at first (the default page size in this application is 25).</p> <p>Unfortunately, to my current understanding, with Google App Engine there is no order to any of the Id's (one entry has an ID of 3 the next has an entry of 4203).</p> <p>What I'm wondering, what is the best way to go about retrieving a subset of data from Google App Engine when using Objectify? </p> <p>I was looking into using Offset and limit but another stack overflow post (http://stackoverflow.com/questions/9726232/achieve-good-paging-using-objectify) basically said this is inefficient.</p> <p>The best information I've found is the following link (http://stackoverflow.com/questions/7027202/objectify-paging-with-cursors). The answer here says to use Cursors but also says this is inefficient. I'm also using Request Factory so I will have to store the Cursor in my user Session (if that is incorrect please let me know).</p> <p>Currently since there isn't likely to be a lot of data (maybe 200 rows total for the next few months) I am just pulling back the entire set to the client as a temporary hack - I know this is the worst way to do it but would like to get input to the best way to do it before wasting my time implementing another hack solution. I am worried currently as it seems every single post i've read on doing this makes it seem like there's not really a solid way to do this. </p> <p>What i am also thinking about doing - currently my searching / page loading is lightning fast because all the data is already on the client side. I use a KeyUpEvent handler in the search box to filter the data - i don't think there is any way to keep this speed by making a call to the server - is there any accepted solution to this problem?</p> <p>Thank you very much</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload