Paging: Find Object-Position (Page) to Display - sql

I'm using .take() and .skip() for paging with a table.
Now when I "insert" an entity into the database, I reload my table (new query). Now I would like to jump to this new object inside the table and highlight it.
Is there an elegant solution to find on what page the new object is and then use skip/take to jump to the correct page?
Edit:
Maybe Breeze/OData could natively support paging by allowing to specify a page-size in the query and which page to deliver (instead of using take and skip and calculating it on the client).
If this was the case, the parameter for "which page to deliver" could, instead of being an integer, also be a sub-query which would be executed on the resulting data before it gets "taked and skipped" to find out, on which page the object(s) are visible and use this as "page to deliver".
Edit 2:
Added the idea to Breeze UserVoice: https://breezejs.uservoice.com/forums/173093-1-breezejs-feature-suggestions/suggestions/6824937-support-paging-natively

It's an interesting idea, but I don't know of any really elegant solution to accomplish this. Conceptually, how would you expect this to work under the covers?

Related

jQuery DataTables: How can I explicitly set the table instance name / table ID to use with state saving?

Background:
I'm using DataTables in conjunction with a JS library called "Turbolinks", which basically turns your application into a Single Page Application (SPA) without all the overhead of using a true client-side framework. It is extremely useful for Ruby on Rails application performance.
There's a couple of headaches it introduces though - one is compatibility with DataTables. I've got it working pretty well by basically destroying any DataTable on a Turbolinks navigation, and then re-initializing it on turbolinks page load again. This method works well and seems to be the all-around accepted answer as to the best practice to get DataTables to work with Turbolinks.
Question:
On of the last features / finishing touches I'm trying to add to some of my applications is DataTable state saving. The issue I'm facing is that every time a table is destroyed/re-initialized on a page navigation, the...I'm actually not quite sure what to call it, but it looks like from inspecting the settings object on the stateSaveCallback - it looks like its the sInstance and/or the sTableId:
DataTables_Table_0
Then the localStorage key gets set as:
DataTables_DataTables_Table_0_/current_path: "{data: data}"
where current_path is whatever path/page you're on.
Then when it get re-initialized upon returning to the page, it gets set as DataTables_Table_1, and so on and so forth - so the state never gets correctly loaded.
Is there a way to override that ID (or some way to set the name of it in the stateSaveCallback / stateLoadCallback) so that it doesn't increase the last '0', '1', etc at the end of it? That way when the table is re-initialized, it will pull the saved state from just DataTables_Table/current_path?
The answer is to simply give the table an ID! Then DataTables won't assign it its own ID with the incrementing number and the saveState option just works.
Also, the destroy/re-init actually causes the server to get hit twice in the case of an AJAX table.
The better way to do it is to disable the turbolinks cache for any index pages with datatables. If not, you'll end up doing two requests to the server when only one is needed.

Slow results when using webkitSpeechRecognition vs x-webkit-speech?

I'm new to using this API and wasnt able to find an answer to what I'm running into.
When I use new webkitSpeechRecognition, and use the onresult event to find isFinal == true, it seems to take longer in finding the final result than using x-webkit-speech in an input tag.
Does anyone know if google is doing something specific to get a speedier result? Or do I need to set an attribute in the webkitSpeechRecognition object?
Thanks for any insight!
See my answer which explains how, in continuous mode results are triggered by new voice input, or otherwise will show up only after a timeout.
In non continuous mode, the result will show up much faster.

GMF Model & Table View

I have been given this task and would appreciate it if someone helped really. I built a Graphical Model through GMF, which is as follows;
As you see one of the nodes in the model has been selected. The task here is to create an eclipse view with a table, which will be automatically updated upon the selection of a so-called "City Node". As you may guess from the model, the table should contain path costs to all of the cities. I will later expand my solution to include a modified Dijkstra Algorithm but right now i am stuck in the creation of a table view.
I tried to build it using a TableViewer but it seems fairly complex since we need to set the input of the table on ContentProvider, but the twist here is that since we need a SelectionListener to obtain the City Coordinates (as it was ordered to calculate path-costs through the distance between two connected cities divided by the max speed, which was indicated on the connecting streets in the graph) and also the currently selected city, the path-costs need to be automatically calculated and displayed in the table upon the receipt of a click-event. This means that we somehow need to update the input which is gonna be handed to ContentProvider on every selection change.
For further information, I get the current selection through selectionChanged method of ISelectionListener interface and inside this method I put the city information in an arraylist. However although i declared this arraylist outside of the method as public, I cannot seem to access it from the outside of the method and thus can not pass it contentProvider. Eventually the input of the table can not be updated. I tried to write this text as simple as possible and I hope you guys can help me. As I can not foresee now what should be done, I would really appreciate it.
You're on the right track!
In your selection listener's ISelectionListener.selectionChanged method you just have to set the new input for the viewer with TableViewer.setInput. Then, the IStructuredContentProvider.inputChanged method gets invoked on the content provider for the viewer. It's here where you can do your stuff with the new input and refresh the viewer with TableViewer.refresh.
You can also use the JFace databinding framework, but I think you should be fine with what I've mentioned above.

Lucene web paging

I am creating a web app with Lucene that I need to implement paging. I have seen here the different examples about using an offset on the collector. However, those seem to be old. Lucene 3.5 (or 3.6 can't remember which) added this I believe. I have seen the IndexSearcher method searchAfter. However, it requires you pass it the last ScoreDoc. Because this is a web app, I have no way to pass the last result (as a ScoreDoc object) to the next request. So, my question is how is this typically done?
The only way that I have really come up with is to add in a unique key into the index when building. Then, pass that key as a post parameter when trying to get the next page. Then, I would have to search for that key to get the document id and pull that document to use with searchAfter. I think I have to use my own unique key because I cannot rely on the document id to stay the same. Am I correct on this?
If there are better ways, please let me know. This is my first attempt at Lucene.
However, it requires you pass it the last ScoreDoc. Because this is a web app, I have no way to pass the last result (as a ScoreDoc object) to the next request. So, my question is how is this typically done?
I don't understand your problem, if you want to use searchAfter, just make a ScoreDoc to pass to it. your webapp can pass ints and floats right?
/** Constructs a ScoreDoc. */
public ScoreDoc(int doc, float score) {
As far as I'm aware, what you are doing at the moment is correct. A ScoreDoc which you construct yourself using ints and floats will not work. See my similar question:
Working Lucene SearchAfter Example

Any documentation available for xe:objectData?

It seems, that the objectData control can be used as a performance boost for an xpage application. I understand the basic idea behind, but still have trouble to get it to work properly.
Using a objectData as input for a repeat control avoids the unneccessary refresh of the repeat during a partial refresh that was triggered on another refreshId than the id for the repeat. But due to the cache mechanism in the objectData, the objectData is not refreshed during a partial refresh of the surrounding div for example. Setting the scope to request, objectData is refreshed, but the issue with partial refresh also refreshing datasources outside the refreshId occurs.
A bit weird, I know, but I do not know, how to explain it better.
So is there any documentation or sample on how to use objectData? Found one sample in the JDBC sampleDb, but it did not help.
In the context of the repeat/specific row use case, introduce Partial Execution (execMode="partial" / execId="foo") to complement the Partial Refresh of the row. This will hone component tree execution to the row of interest and avoid redundant processing outside of the specified target area.
In terms of documentation for objectData, the best worked example is indeed within the XPagesJDBC.nsf sample database (JDBC_RowSetDatasource.xsp) - it succinctly demonstrates using this datasource as a delegate to create a specialized DataContainer object from the current "row" variable, and conversely managing the specialized saving of the DataContainer object during the save process. Although this example handles the delegation of SQL processing for the current row, the same approach is applicable under many use cases (eg: one example, the underlying view could be a view of XML documents, where you need to delegate per row handling using the objectData datasource through a custom specialized XML processing object).