I have an async table which inserts & deletes rows that are persisted in a database
.
My question is - If there are no rows to display the table still shows an initial empty row which I am trying to use to insert data in the usual way, unfortunately this doesn’t work correctly & no row is inserted.
Normally - when there is at least one row of data - inserts, deletes & updates work as expected BUT the problem arises when the table is initially empty.
I can overcome this by using the Add Row button to create a new row and insert the data here, but that seems counter intuitive & ugly!
So I discovered that the actual problem is caused by the the web service connector/flow mechanism.
When the adapter returns no rows from the DB the flow returns an empty document, representing the row, as this has to be in the flows output for it to return any information.
This is the empty row being shown in the table!
I use an async command LINK to action a method which inserts new rows but when attempting the same using the row shown, the log just reports that the row is not found
row not found: __row
I noted that the row has an index/id of “_row” whereas when I add a new row using the add row button the index shows as “_row_new***” (where *** is a random number).
This is the provider at before render response
I think that the easiest solution would be to somehow remove the empty initial row from the provider in the before render response so I set the result of the web service & the provider both to null as below.
if (getProvider().getRowIndex() < 0) {
getWebService().getResult().setResults(null);
getProvider().setArray(null);
}
This gives me a table without the blank row, now I add a row using the add row button and update as normal but get a null pointer when testing the provider for row values.
getProvider().getValue("field1");
I understood the provider would be aligned on the row selected as it is normally so maybe setting it to null is wrong but I can’t see how else to set it to empty & not show the empty row
Before evaluating the workarounds, lets consider the root cause.
If the initial empty row has an id of “_row” then that suggests that the expression you have chosen for the rowId of the table content provider is returning an empty string.
Can you change the flow service to populate the id field of your document with some non-empty value so that row can be uniquely identified?