0

e.g. we have this one guy calling server function for creating a new entity:

function loadData() {
    var vServerController = mobileController.serverController();    
    var vJSONRequest =  vServerController.createJSONRPCRequest();

    vJSONRequest.setQueryMethod("createSomeNewElementBasedOnTwoIds");

    vJSONRequest.addParameter("firstID", 1);
    vJSONRequest.addParameter("secondID", 2);
    vJSONRequest.setOnFinish(callBackOnFinish);
    vServerController.addToQueue(vJSONRequest);
}

function callBackOnFinish() {
    var vController = mobileController.activeController();
    vController.showView(Screens.SomeScreen, true);
}

So how we can refresh a Screen after this call? The server will return not a full set of data but just a new one.

What is the best approach to doing this?

Werner Henze
  • 16,404
  • 12
  • 44
  • 69

1 Answers1

0

Assuming you want to update the currently displayed data, you have two options - and you propably don't need to use a callback for this

  1. Replace the displayed dataset
  2. Update the displayed record
  3. (if you had user input or created a new entry) merge the entries

1: just return the data from the server with foundset.setDataMode(DataMode.REPLACE) - it will automatically refresh the displayed data. But In case you are working with multiple records for one entity and you only want to update one of them, use option 2.

2: Return only the specific record you want to update without datamode replace. The record is identified by it's key/id elements. You can find those marked with a little key symbol in the entity editor. So just make sure that those key elments and any additionaly elements you want are returned. The AppConKit will automatically merge the existing record with the data and display that.

3: If you created a new record on the device, that record will have a value called client_uuid. If you now return a record from the server that contains both the client_uuid AND the key element, the record created on the device will be merged with the server created record and the new record will displayed

Hope this helps!

Blitz
  • 5,521
  • 3
  • 35
  • 53
  • ,thx. actually i was not aware about third posibility. can you please give me a hint, how to create a new data record on the device? – Anton Pfennig Jul 11 '13 at 10:43
  • Manually by using the `newRecord` API or automatically if you present a view that has no data loaded https://customer.weptun.de/display/ACK3/Foundset+API#FoundsetAPI-Foundset.newRecord%28%29 – Blitz Jul 11 '13 at 12:51