485
edits
(Created page with "From this forum post: https://support.dataaccess.com/Forums/showthread.php?68231-ToDo-Describe-call-mode-and-a-few-more-questions&p=371095#post371095 Reposting it here so I can quickly find it next time I need it (sorry, not sorry) It is indeed true that for most situations the tWebValueTree is not needed any more. ClientActions and ServerActions can now use JSON Handles or structs & arrays that are directly serialized. So when calling a server action you can now do th...") |
m (formatting) |
||
Line 4: | Line 4: | ||
It is indeed true that for most situations the tWebValueTree is not needed any more. ClientActions and ServerActions can now use JSON Handles or structs & arrays that are directly serialized. So when calling a server action you can now do the following: | It is indeed true that for most situations the tWebValueTree is not needed any more. ClientActions and ServerActions can now use JSON Handles or structs & arrays that are directly serialized. So when calling a server action you can now do the following: | ||
<source lang="javascript"> | |||
// Create data objects | // Create data objects | ||
var oData = { | var oData = { | ||
Line 22: | Line 22: | ||
alert(oEvent.sReturnValue); | alert(oEvent.sReturnValue); | ||
}); | }); | ||
</source> | |||
<source lang="dataflex"> | |||
// Function called as server action | // Function called as server action | ||
Function ProcessData2 Integer iParam1 Integer iParam2 Returns String | Function ProcessData2 Integer iParam1 Integer iParam2 Returns String | ||
Line 36: | Line 36: | ||
Function_Return tData.labels[3] | Function_Return tData.labels[3] | ||
End_Function | End_Function | ||
</source> | |||
So instead of ptActionData you use phoActionJsonData which gives a cJsonObject representing the data. Note that you do not have to cleanup this JSON Handle. | So instead of ptActionData you use phoActionJsonData which gives a cJsonObject representing the data. Note that you do not have to cleanup this JSON Handle. | ||
For client actions you can do the following: | For client actions you can do the following: | ||
<source lang="dataflex"> | |||
Procedure ProcessDataOnClient2 | Procedure ProcessDataOnClient2 | ||
// Send the client action | // Send the client action | ||
Line 57: | Line 58: | ||
Send ClientAction "processData2" aParams tData | Send ClientAction "processData2" aParams tData | ||
End_Procedure | End_Procedure | ||
</source> | |||
<source lang="javascript"> | |||
// Client action called with action data | // Client action called with action data | ||
processData2 : function(){ | processData2 : function(){ | ||
Line 70: | Line 72: | ||
alert(tData.datasets[0].strokeColor); | alert(tData.datasets[0].strokeColor); | ||
} | } | ||
</source> | |||
Note that ClientAction takes a variant parameter that it serializes to JSON. Both API's are backwards compatible so working with tWebValueTree still works. The value tree's are also still used for client web properties. | Note that ClientAction takes a variant parameter that it serializes to JSON. Both API's are backwards compatible so working with tWebValueTree still works. The value tree's are also still used for client web properties. |