2

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 adapter:

    function getFeeds() {
        WL.Logger.debug("inside method");

        var input = {
            method : 'get',
            returnedContentType : 'json',
            path : "ios/clientRegister.php",
            parameters:{
              "employeenumber":"500","employeename":"Harish","employeeemail":"anand5@gmail.com","city":"Delhi", 
              "employeeadID":"an6458","businessUnit":"WASE","country":"India","city":"Bengaluru","location":"EC4","bloodGroup":"B+ve", "gender":"Male","tShirt":"xl"    
            }  
        };
        return WL.Server.invokeHttp(input);
    }
Sadanand
  • 107
  • 2
  • 11

1 Answers1

1

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:

  1. Open the Servers view in Eclipse

  2. Expend the Worklight Development Server entry

  3. Double-click on Server Configuration

  4. Click on Logging

  5. Change the Console log leve from AUDIT to INFO (using the dropdown)

    Full size image: https://i.stack.imgur.com/9llHc.png enter image description here

  6. You may need to Project >> Clean...

  7. The outcome will be in the Console view for the Worklight Development Server

    Full size image: https://i.stack.imgur.com/x2Hv1.png enter image description here

Community
  • 1
  • 1
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • Please share the information on how to see the logged data/lines. I have to use this in all other test cases to analyze the behaviour of the worklight. Thanks a lot.... – Sadanand Jul 25 '13 at 09:10
  • It depends on your Worklight version. What is your Worklight version? See my updated answer with instructions for Worklight 6.0. In any case, if my answer helped you understand how to pass parameters (which is what this question is about), please mark as Answered. Thanks! – Idan Adar Jul 25 '13 at 09:39
  • Once again Thanks a lot for your valuable information Idan Adar. – Sadanand Jul 25 '13 at 09:56
  • How to use validation in the options and how to get drop down for one selected item(like we use spinners in android). – Sadanand Jul 25 '13 at 11:35
  • Not related to this question (nor to Worklight). – Idan Adar Jul 25 '13 at 11:36
  • country: for this I want to have drop down menu. How to query the database in php. Plz share the information. Thanks. – Sadanand Jul 25 '13 at 11:38
  • Open a new question with the php tag. This is not related to Worklight. Comments are not meant for questions. – Idan Adar Jul 25 '13 at 11:40