IBM Worklight - How to pass parameters from the application to the adapter?

前端 未结 1 1936
借酒劲吻你
借酒劲吻你 2021-01-22 02:11

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

1条回答
  •  被撕碎了的回忆
    2021-01-22 03:10

    You can pass the parameters using simple JavaScript.
    For example:

    HTML

    First name: 
    Last 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

    
    

    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: http://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: http://i.stack.imgur.com/x2Hv1.png enter image description here

    0 讨论(0)
提交回复
热议问题