Moving from smartGWT12.1 to v13.0p_2023-04-25/ we came across a grid that no longer saves user changes. The UI spits out the Warning pop up : "getLastPrimiaryKeys() called before valid insert/replace/update operation has been performed" . Our ListGrid uses ListGrid.startEditingNew(...) and saveAllEdits() to create a new record, initializing some fields like modified time in the code and user facing fields via standard List Grid cell edit user input.
Has anything changed that would cause that warning?
Also, in the server constructor's executeUpddate routine I'm looking at code that determines that a record is brand new via getValues() PrimaryKey == -1, then creates a new DSRequest to add the base record with a super.executeAdd(). The add uses the serverConstructors executeUpdate methods DSRequest parameter's getOldValues() as the values to add for the new record. The values the user added via the ListGrid row edits are contained in the request's getNewValues(). They would be added next, by a super.executeUpdate() call, if not for the Warning that gets produces from the Add.
i.e.
Has anything changed that would cause that warning?
Also, in the server constructor's executeUpddate routine I'm looking at code that determines that a record is brand new via getValues() PrimaryKey == -1, then creates a new DSRequest to add the base record with a super.executeAdd(). The add uses the serverConstructors executeUpdate methods DSRequest parameter's getOldValues() as the values to add for the new record. The values the user added via the ListGrid row edits are contained in the request's getNewValues(). They would be added next, by a super.executeUpdate() call, if not for the Warning that gets produces from the Add.
i.e.
Code:
@Override public DSResponse executeUpdate(DSRequest req) throws Exception { if ("vanillaUpdate".equalsIgnoreCase(req.getOperationId())) { return super.executeUpdate(req); } com.isomorphic.datasource.DataSource ds = req.getDataSource(); String dsName = ds.getName(); String keyName = ds.getPrimaryKey(); Map<String, Object> recordMap = req.getValues(); if (recordMap != null && recordMap.containsKey(keyName) && (Long) recordMap.get(keyName) == -1) { recordMap.remove(keyName); // There seems to be an issue when adding new Checklist items - specifically // with the multiple FK_Userid_* fields // Adding transforms to an encoded list, while updates keep the string // (correctly) intact. // So add in 2 parts: // 1. Add the record with just the basics from oldValues( FK_idProject, tabId, // etc) // 2. Update the remaining fields after you've inserted the record... DSRequest addRow = new DSRequest(dsName, "add"); if ( req.getOldValues() != null) { addRow.setValues(req.getOldValues()); } DSResponse addResponse = super.executeAdd(addRow); // esdebug why isn't this working like in 12.1? debug shows it kicks out here. List<Map> queryResults = addResponse.getDataList(); Map map = queryResults.get(0); for (Object key : map.keySet()) { if (!recordMap.containsKey(key.toString())) { recordMap.put(key.toString(), map.get(key)); } } req.setValues(recordMap); req.setCriteria(keyName, map.get(keyName)); return super.executeUpdate(req); } return super.executeUpdate(req); }
Comment