This has got nothing to do with Dojo per-se. Worklight doesn't care which framework you're using for your application's UI, as long as you're using the Worklight API correctly. Meaning, as long as you pass the values-to-be-inserted to the adapter call.
See my answer here for an end-to-end example: https://stackoverflow.com/a/25164028/1530814
In the below example I pass the values directly using jQuery: $('#value1').val()
, but it can be done in other ways too.
HTML:
<h1>Test Insert Into Database</h1>
<input type="text" id="value1" placeholder="value1"/><br/>
<input type="text" id="value2" placeholder="value2"/><br/>
<input type="button" value="Insert values to database" onclick="insertValuesToDB();"/>
main.js:
function insertValuesToDB() {
var invocationData = {
adapter: 'insertValuesAdapter',
procedure: 'insertValuesProcedure',
parameters: [$('#value1').val(), $('#value2').val()]
};
WL.Client.invokeProcedure(invocationData, {onSuccess: insertSuccess, onFailure: insertFailure});
}
function insertSuccess() {
alert("success");
}
function insertFailure() {
alert("failure");
}
Adapter XML:
...
...
<connectivity>
<connectionPolicy xsi:type="sql:SQLConnectionPolicy">
<dataSourceDefinition>
<driverClass>com.mysql.jdbc.Driver</driverClass>
<url>jdbc:mysql://localhost:3306/worklight_training</url>
<user>Worklight</user>
<password>Worklight</password>
</dataSourceDefinition>
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="5" />
</connectivity>
<procedure name="insertValuesProcedure"/>
...
...
Adapter implementation:
var insertValuesProcedureStatement = WL.Server.createSQLStatement("INSERT INTO users(userId, firstName, lastName, password) VALUES (?,?, 'someLastName', 'somePassword')");
function insertValuesProcedure(value1,value2) {
return WL.Server.invokeSQLStatement({
preparedStatement : insertValuesProcedureStatement,
parameters : [value1,value2]
});
}