As Blama described in http://forums.smartclient.com/showthread.php?t=31347 , this is exactly what I am doing here:
my view datasource is "testDatasource", while my update datasource is "vertraege". In this special test case, both are equal. But in my real application, they are very different. But still, the issue is the same. Are you able to reproduce the problem?
Announcement
Collapse
No announcement yet.
X
-
I don't quite understand what you mean.
In the testcase I have two datasources which are basically equal, yes. In my original application this is different: I have two very different datasources, but the problem is the same: that the listgrid's datasource doesn't update correctly when updating the other datasource. So, in my application, the data returned as the normal update data and the related update are very different.
In my testcase they are the same only in order to keep it simple .. but the issue is the same.
Leave a comment:
-
You've got the same data being returned as the normal update data *and* as a relatedUpdate. This is not necessarily invalid but it's definitely redundant. Does the problem go away for you if you stop doing this?
Leave a comment:
-
Reading the docs/forum posts, and after creating a test case, I think this is a bug. Maybe it is related/specific to MSSQL 2014, since we had in the past serious bugs/issues related to this? E.g. http://forums.smartclient.com/showthread.php?t=31159 , or http://forums.smartclient.com/showthread.php?t=28397
My testcase:
EntryPoint:
Code:public class TestingModule implements EntryPoint { public void onModuleLoad() { VLayout vlayout = new VLayout(); IButton button = new IButton("Click ME"); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { new MyWindow3().show(); } }); vlayout.addMember(button); vlayout.draw(); } }
Code:public class MyWindow3 extends Window { private final ListGrid lg; private final IButton button; private Integer actualStatus = 1; TextItem idItem; public MyWindow3() { setWidth(1050); setHeight(760); setAutoCenter(true); setIsModal(true); setShowModalMask(true); setShowMaximizeButton(true); VLayout vlayout = new VLayout(12); vlayout.setPadding(25); lg = new ListGrid(); lg.setDataSource(DataSource.get("testDatasource")); lg.setWidth("100%"); lg.setHeight(400); lg.setSortField("f_id"); lg.setAutoFetchData(false); HLayout buttonsLayout = new HLayout(15); buttonsLayout.setHeight(25); buttonsLayout.setAlign(Alignment.LEFT); DynamicForm df = new DynamicForm(); idItem = new TextItem("id"); df.setFields(idItem); buttonsLayout.addMember(df); button = new IButton("Switch status"); button.setWidth(200); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { onButtonClick(); } }); buttonsLayout.addMember(button); vlayout.addMember(lg); Criteria c = new Criteria(); c.addCriteria("f_vertrag_status", 1); lg.fetchData(c); vlayout.addMember(buttonsLayout); addItem(vlayout); } private void onButtonClick() { Record updateRec = new Record(); updateRec.setAttribute("f_id", Integer.parseInt(idItem.getValueAsString())); Integer newStatus = null; if (actualStatus.intValue() == 1) { newStatus = 3; } else { newStatus = 1; } updateRec.setAttribute("f_vertrag_status", newStatus); actualStatus = newStatus; DataSource.get("vertraege").updateData(updateRec, new DSCallback() { @Override public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) { SC.say("OK"); } }); } }
Code:<DataSource ID="testDatasource" serverType="sql" tableName="t_vertrag"> <fields> <field name="f_id" type="sequence" primaryKey="true" /> <field name="f_vertrag_status" type="integer" /> </fields> </DataSource>
Code:<DataSource ID="vertraege" serverType="sql" tableName="t_vertrag" > <fields> <field name="f_id" type="sequence" primaryKey="true" /> <field name="f_vertrag_status" type="integer" /> </fields> <operationBindings> <operationBinding operationType="update"> <serverObject className="myCompany.app.server.dmi.StatusDMIHandler" methodName="doUpdate" /> </operationBinding> </operationBindings> </DataSource>
Code:public class StatusDMIHandler { public DSResponse doUpdate(DSRequest dsRequest, HttpServletRequest servletRequest) throws Exception { DSResponse response = dsRequest.execute(); RPCManager rpcManager = dsRequest.getRPCManager(); Integer vertragId = null; Object vertragIdObject = dsRequest.getCriteria().get("f_id"); if (vertragIdObject instanceof Long) { vertragId = Integer.valueOf(((Long) vertragIdObject).intValue()); } else { vertragId = (Integer) vertragIdObject; } DSRequest schuelerRequest = new DSRequest( "testDatasource", DataSource.OP_FETCH, rpcManager); Map<String, Object> criteria = new HashMap<String, Object>(); criteria.put("f_id", vertragId); schuelerRequest.setCriteria(criteria); DSResponse schuelerResponse = schuelerRequest.execute(); schuelerResponse.setOperationType(DataSource.OP_UPDATE); response = response.addRelatedUpdate(schuelerResponse); return response; } }
Then you can choose one id (writing it on the textField below), and push the button "switch". The f_vertrag_status = 3 is set, and so it should disappear from the listGrid because of the criteria.
Then, pussing the button "switch" again, f_vertrag_status = 1 is set. This record should appear again at the listGrid.
So, step by step:
1) Suppose you have a record with f_id=511 and f_vertrag_status=1, so it is shown in the listGrid.
Logs until now:
Code:19:00:07.069:INFO:Log:initialized 19:00:19.653:INFO:Log:isc.Page is loaded 19:00:21.366:MUP1:INFO:ResultSet:isc_ListGrid_0:Creating new isc.ResultSet for operation 'testDatasource_fetch' with filterValues: { "f_vertrag_status":1 } 19:00:21.375:MUP1:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):setCriteria: filter criteria changed, invalidating cache 19:00:21.375:MUP1:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):Invalidating cache 19:00:21.396:MUP1:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(0,1), cache check: 0,37 firstMissingRow: 0 lastMissingRow: 37 19:00:21.396:MUP1:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange: guessing forward scrolling 19:00:21.396:MUP1:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(0, 1) will fetch from 0 to 75 19:00:21.396:MUP1:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):fetching rows 0,75 from server 19:00:21.864:MUP1:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(0, 24) satisfied from cache 19:00:22.012:XRP6:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):Received 75 records from server 19:00:22.013:XRP6:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):full length set to: 1603 19:00:22.013:XRP6:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):integrating 75 rows into cache at position 0 19:00:22.014:XRP6:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):cached 75 rows, from 0 to 75 (1603 total rows, 75 cached) 19:00:22.040:TMR7:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(0, 24) satisfied from cache
3) Push "switch".
The record disappears. This is the expected behavior.
The logs also show this correctly (updated cache: 0 row(s) added, 0 row(s) updated, 1 row(s) removed.).
Logs:
Code:19:03:03.484:XRP8:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):dataSource data changed firing 19:03:03.485:XRP8:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):updating cache in place after operationType: update, cached rows: 75, total rows: 1603 19:03:03.486:XRP8:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):Updating cache: operationType 'update' (no componentID) ,1 rows update data: [ {f_id: 511, f_vertrag_status: 3} ] 19:03:03.490:XRP8:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):row dropped: {f_id: 511, f_vertrag_status: 3} didn't match filter: { "f_vertrag_status":1 } 19:03:03.490:XRP8:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):updated cache: 0 row(s) added, 0 row(s) updated, 1 row(s) removed. 19:03:03.569:TMR1:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(0, 24) satisfied from cache
Code:{ dataSource:"vertraege", operationType:"update", data:{ f_id:511, f_vertrag_status:3 }, textMatchStyle:"exact", showPrompt:true, oldValues:{ f_id:511, f_vertrag_status:3 }, requestId:"vertraege$6271", fallbackToEval:false, lastClientEventThreadCode:"MUP5", bypassCache:true }
Code:[ { affectedRows:1, data:[ { f_id:511, f_vertrag_status:3 } ], invalidateCache:false, isDSResponse:true, operationType:"update", queueStatus:0, relatedUpdates:[ { endRow:1, affectedRows:0, dataSource:"testDatasource", totalRows:1, isDSResponse:true, invalidateCache:false, status:0, operationType:"update", startRow:0, data:[ { f_id:511, f_vertrag_status:3 } ] } ], status:0 } ]
The record DOES NOT APPEAR again, which I think is not correct. Nevertheless, the logs say that the record should have appeared: (updated cache: 1 row(s) added, 0 row(s) updated, 0 row(s) removed.).
But I DON'T SEE the record 511 supposely added. Nothing happens with the listGrid. So what is happening here ??
Code:19:06:12.296:XRP5:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):dataSource data changed firing 19:06:12.297:XRP5:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):updating cache in place after operationType: update, cached rows: 74, total rows: 1602 19:06:12.299:XRP5:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):Updating cache: operationType 'update' (no componentID) ,1 rows update data: [ {f_id: 511, f_vertrag_status: 1} ] 19:06:12.303:XRP5:WARN:Log:findByKeys: passed record does not have a value for key field 'f_id' 19:06:12.305:XRP5:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):updated row returned by server doesn't match any cached row, adding as new row. Primary key values: {f_id: 511}, complete row: {f_id: 511, f_vertrag_status: 1} 19:06:12.305:XRP5:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):updated cache: 1 row(s) added, 0 row(s) updated, 0 row(s) removed. 19:06:12.394:TMR9:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(0, 24) satisfied from cache
Code:{ dataSource:"vertraege", operationType:"update", data:{ f_id:511, f_vertrag_status:1 }, textMatchStyle:"exact", showPrompt:true, oldValues:{ f_id:511, f_vertrag_status:1 }, requestId:"vertraege$6272", fallbackToEval:false, lastClientEventThreadCode:"MUP2", bypassCache:true }
Code:[ { affectedRows:1, data:[ { f_id:511, f_vertrag_status:1 } ], invalidateCache:false, isDSResponse:true, operationType:"update", queueStatus:0, relatedUpdates:[ { endRow:1, affectedRows:0, dataSource:"testDatasource", totalRows:1, isDSResponse:true, invalidateCache:false, status:0, operationType:"update", startRow:0, data:[ { f_id:511, f_vertrag_status:1 } ] } ], status:0 } ]
Leave a comment:
-
addRelatedUpdate question
I have a listGrid which always displays some values depending on some criteria, let's say where field1 == "A".
If I update one of the records in another component using another datasource, I use addRelatedUpdate() on the server-side. This uses an UPDATE dsResponse for this.
So let's say I update the record to: field1 = "B" and call addRelatedUpdate().
Then, the record disappears from the listGrid since it gets an update and the criteria hide records having field1 != "A". This is correct.
But the other way around is not working:
I have a record with field = "B". I update the value to "A" somewhere else and call addRelatedUpdate().
The record is not appearing in the listGrid! Is this the normal behavior? And what can I do to correct this ?
Using smartGWT 4.1p Power.Tags: None
Leave a comment: