FWLSE0013E:无法调用过程JSONObject无法强制转换为JSONArray

时间:2016-04-13 20:57:45

标签: javascript json ibm-mobilefirst

我的IBM Mobile第一个名为login的应用程序中有一个clinet端功能 我从这个link得到它。

login: function (username,password){    
            //promise
            var logindef = $q.defer();
            //tempuser
            tempUser = {username:username, password:password};
            userObj.username = username;
            checkOnline().then(function (onl){
                if (onl){ //online
                    console.log("attempting online login");
                    var parameters={
                            'username':'username',
                            'password':'password'
                        };
                    var options = {
                        parameters:parameters,  
                        adapter:"realmAuth",
                        procedure:"submitLogin"
                    };
                    ch.submitAdapterAuthentication(options,{
                        onSuccess: function(){
                            console.log("-> submitAdapterAuthentication onSuccess!");
                            //update user info, as somehow isUserAuthenticated return false without it
                            WL.Client.updateUserInfo({onSuccess: function(){    
                                //return promise
                                logindef.resolve(true);
                            }});
                        }
                    });
                } else { //offline
                    console.log("attempting offline login");
                    logindef.resolve(offlineLogin());
                }
            });
            return logindef.promise;
        },

我想调用名为submitLogin

的适配器函数
function submitLogin(parameters){
        if (!parameters)
        return { 'isSuccessful': false, 'errorMsg' : 'parameters is ' + parameters};
        var role="";
        if (parameters.username=='admin') 
            role='admin';
        else
            role='customer';
        var input = {
                method : 'post',
                returnedContentType : 'plain',
                path : 'rest/default/V1/integration/' + role + '/token'+
                            '?username='+parameters.username+
                            '&password='+parameters.password,
                headers: {"Accept":"application\/json"} 
            };
            var response = WL.Server.invokeHttp(input);
            var token=response.text;
            token = token.replace("\"", "");            //delete the ""
            token = token.replace("\"", "");*/
            //token exp: l9ea4tv62mbfy7kmt0ekv6vdxmb23gjp
            if (token!=null) 
            { 
                var userIdentity = {
                        userId: parameters.username,
                        displayName: parameters.username, 
                        attributes: {
                            foo: "bar"
                        }
                };
                WL.Server.setActiveUser("AdapterAuthRealm", userIdentity); 

                return { 
                    authRequired: true 
                };
            }

    return onAuthRequired(null, "Invalid login credentials");
}

当我尝试在导航器中执行我的应用程序时,我收到此错误:

  

[ERROR] FWLSE0013E:无法调用过程realmAuth / submitLogin [project Eticket] com.ibm.json.java.JSONObject无法强制转换为com.ibm.json.java.JSONArray

1 个答案:

答案 0 :(得分:1)

您的bool ImageWidget::gestureEvent(QGestureEvent *event) { if (QGesture *swipe = event->gesture(Qt::SwipeGesture)) swipeTriggered(static_cast<QSwipeGesture *>(swipe)); return true; } void ImageWidget::swipeTriggered(QSwipeGesture *gesture) { if (gesture->state() == Qt::GestureFinished) { if (gesture->horizontalDirection() == QSwipeGesture::Left) { // highlight the right widget , you could even bring it to center } else if (gesture->horizontalDirection() == QSwipeGesture::Right) { // highlight the left widget , you could even bring it to center } } } 数组格式不正确。

您写道:

parameters

Javascript适配器需要未命名,有序的参数列表。不是JSON对象。

应该是:

var parameters={
                'username':'username',
                'password':'password'
                };

您的适配器签名当然应该相应更改,从var parameters = ['myUsername','myPassword'] function submitLogin(parameters)