I want to pass parameters from the application to the adapter; I want the users of the app to enter these options.
Right now I am passing the parameters like this in ada
You can pass the parameters using simple JavaScript.
For example:
HTML
First name: <input type="text" id="firstname"/>
Last name: <input type="text" id="lastname"/>
<input type="button" onclick="submitName()" value="Submit Name"/>
App JS
function submitName() {
var invocationData = {
adapter : 'exampleAdapter',
procedure : "showParameters",
parameters : [$('#firstname').val(),$('#lastname').val()]
};
var options = {
onSuccess : success,
onFailure : failure
};
WL.Client.invokeProcedure(invocationData, options);
}
function success() {
alert ("success");
}
function failure() {
alert ("failure");
}
Adapter XML
<procedure name="showParameters"/>
Adapter implementation
function showParameters(firstname, lastname) {
WL.Logger.info ("The submitted parameters are: '" + firstname + "' and '" + lastname + "'");
}
To actually see the logged line you'll need to:
Open the Servers view in Eclipse
Expend the Worklight Development Server
entry
Double-click on Server Configuration
Click on Logging
Change the Console log leve from AUDIT
to INFO
(using the dropdown)
Full size image: http://i.stack.imgur.com/9llHc.png
You may need to Project >> Clean...
The outcome will be in the Console view for the Worklight Development Server
Full size image: http://i.stack.imgur.com/x2Hv1.png