Titanium - Requested module not found: alloy/controllers/undefined - titanium

I'm just following the guide on appcelerator, but something doesn't work.
This is the error message:
TiExceptionHandler: (main) [0,29887] - In ti:/module.js:280,9
[ERROR] : TiExceptionHandler: (main) [0,29887] - Message: Uncaught Error: Requested module not found: alloy/controllers/undefined
[ERROR] : TiExceptionHandler: (main) [1,29888] - Source: throw new Error("Requested module not found: " + request);
[ERROR] : V8Exception: Exception occurred at ti:/module.js:280: Uncaught Error: Requested module not found: alloy/controllers/undefined
index.js:
$.index.open();
var myBooks = Alloy.Collections.books;
var book = Alloy.createModel("books",{
title: "Great Expectations",
author: "Charles Dickens"
});
myBooks.add(book);
book.save();
function showBook(event){
console.log( event );
var selectedBook = event.source;
var args = {
title: selectedBook.title,
author: selectedBook.author
};
var bookView = Alloy.createController("bookdetails". args).getView();
bookView.open();
}
bookdetails.js:
var args = arguments[0] || {};
$.titleLabel.text = args.title || "Default Title";
$.authorLabel.text = args.author || "Default author";

When defining a new view with the controller if you want to pass multiple parameters as arguments to the controller they they need to be delimited in comma separated list.
Alloy.createController('viewname', args).getView();
Your full stop is causing alloy to throw the exception.

Related

Render a template in a onchage of text field in odoo 14

I am trying to render a template in onchange of a input field.
Here is the onchange method.
*.js
_onClickBasketInputChange: function(){
console.log('inside input change',this.basketVerificationId);
var self = this;
var barcode = $('.basket_barcode_input').val();
console.log('barcode',barcode);
// var rec = this._rpc({
return this._rpc({
model: 'mobile.basket.verification',
method: 'get_picking_details',
args: [this.basketVerificationId,barcode],
}).then(function(res){
// console.log('this',self);
console.log('picking_id',res);
var $body = this.$el.filter('.o_barcode_lines');// Here i am getting the error ' Uncaught (in promise) TypeError: this is undefined'
console.log('body',$body);
if (res['status'] == true){
console.log('successs');
var $lines = $(Qweb.render('basketVerificationLines', {
picking:res['picking_id'],
customer:res['partner_id'],
lines:res['line_ids']
}));
$body.prepend($lines);
}
// $('.basket_barcode_input').val('');
var message = res['result'];
if (res['status'] == false){
Dialog.alert(self, message);
}
});
},
But i am getting following error
Uncaught (in promise) TypeError: this is undefined
Update:
When change this to self, the value of $body is
body
Object { length: 0, prevObject: {…} }
​
length: 0
​
prevObject: Object { 0: div.o_action, length: 1 }
​
And the template not prepend to the body.
Please help to resolve this.
I got the solution,
I replace the .filter with .find then it works.
var $body = self.$el.find('.o_barcode_lines');

How to call Azure function from Kotlin

I currently have deployed an Azure function used to get an AD token.
Function:
https://getadtokennet.azurewebsites.net/api/getadtokennet
Request header:
x-functions-key = {key}
How can I call this function from my Kotlin app?
This is the way I call it from Javascript
function getTokenAzure(onsuccess, onerror) {
var tokenUrl = 'https://getadtokennet.azurewebsites.net/api/getadtokennet';
$.ajax(tokenUrl, {
method: 'GET',
beforeSend: function (request) {
request.setRequestHeader("x-functions-key", "function key");
},
success: function (data) {
onsuccess(data);
console.log('token: ' + data.token);
},
error: function (xhr, status, error) {
var failureMessage = "GetToken error: " + status + " - " + error;
onerror(failureMessage);
console.log(failureMessage);
}
});
}
In IntelliJ IDEA, select Create New Project.
In the New Project window, select Maven from the left pane.
Select the Create from archetype check box, and then select Add Archetype for the azure-functions-kotlin-archetype.
In the Add Archetype window, complete the fields as follows:
GroupId: com.microsoft.azure
ArtifactId: azure-functions-kotlin-archetype
Version: Use the latest version from the central repository
Select OK, and then select Next.
Enter your details for current project, and select Finish.
For complete information refer to the below links which has same information.
Kotlin Function and Running Kotlin in Azure Functions
I found the way, here it is.
fun getToken(): String {
val tokenUrl = URL("https://getadtokennet.azurewebsites.net/api/getadtokennet")
val connection = tokenUrl.openConnection() as HttpURLConnection
connection.requestMethod = "POST"
connection.setRequestProperty("x-functions-key", "function key")
connection.doOutput = true
val responseCode = connection.responseCode
if (responseCode == HTTP_OK) {
val readerIn = BufferedReader(InputStreamReader(connection.inputStream))
var inputLine = readerIn.readLine()
val response = StringBuffer()
do {
response.append(inputLine)
} while (inputLine.length < 0)
readerIn.close()
// Return token
return response.toString()
} else {
val responseError = Error(code = "BadRequest", message = "There was an error getting the token.")
throw IOException(responseError.toString())
}
}

Error during loading: Uncaught ReferenceError: jqxBaseFramework is not defined

Error during loading: Uncaught ReferenceError: jqxBaseFramework is not defined in http://localhost:9876/_karma_webpack_/vendor.js line 125124
getting this error in jasmin unit testing
switch (item) {
case 'Add Privilage':
selectedItem = this.myTree.getSelectedItem();
// document.getElementById("Update").click();
if (selectedItem != null) {
this.selectedParentName = selectedItem.label;
this.selectedParentUId = selectedItem.value.privilegeId;
this.showAddPrivilageDiv = true;
// this.myTree.addTo({ label: 'Item' }, selectedItem.element);
}

SQLAdapter in MobileFirstPaltform giving error

I am calling SQLAdapter from below adapter:
function callFetchBalance(msisdn, circle,imei) {
try {
var response = WL.Server.invokeProcedure({
adapter : "sqladapter",
procedure : "checkIMEIAndMSISDN",
parameters : [ msisdn,imei ]
});
if(response.isSuccessful){
if(typeof response.resultSet[0]!== 'undefined' && null!=response.resultSet[0]) {
var count = response.resultSet[0].COUNT;
if(count!='1.0'){
return {
exception_code : "403"
}
}else{
var callMethod = new com.actions.Util();
var balanceReturned = callMethod.getBalance(msisdn, circle);
return {
balance : balanceReturned
};
}
}else{
return {
balance : "null"
};
}
}else{
return {
balance : "null"
};
}
} catch (e) {
return {
balance : "null"
};
}
}
And my adapter is like this:
var checkIMEIAndMSISDN = WL.Server.createSQLStatement("select count(*) as count from AUTH_TABLE where MSISDN=? and IMEI=?");
function checkIMEIAndMSISDN(msisdn,imei) {
var response = WL.Server.invokeSQLStatement({
preparedStatement : checkIMEIAndMSISDN,
parameters : [msisdn,imei]
});
return response;
}
But on running this, I am getting below error:
[8/21/17 17:42:29:036 IST] 000000be DataAccessSer E logError FWLSE0099E: An error occurred while invoking procedure [project UtilApp]sqladapter/checkIMEIAndMSISDNFWLSE0100E: parameters: [project UtilApp]
org.mozilla.javascript.NativeJavaObject incompatible with org.mozilla.javascript.Function
FWLSE0101E: Caused by: [project UtilApp]nulljava.lang.ClassCastException: org.mozilla.javascript.NativeJavaObject incompatible with org.mozilla.javascript.Function
at com.worklight.integration.js.JavaScriptManager.getFunction(JavaScriptManager.java:260)
Also from the log, it is showing caused from below line:
var response = WL.Server.invokeProcedure({
Someone please suggest me whats wrong in this line or I am getting this error due to some other code.

JSON Store in worklight v6.0

I am trying to integrate the JSONStore standalone app in my multipage application. When I am trying to initialize the collection I am getting the following error "Uncaught TypeError: undefined is not a function". One thing I want to know is, in Worklight version 6.0 I observed that underscore (Lo-Dash) templating was used. But nowhere I found the reference given to the lodash. Also, I didn't find the lodash file anywhere. can anyone please tell me how to do this?
Here is my javascript code
window.$ = window.jQuery = WLJQ;
currentPage = {};
currentPage.init = function(WL, jQuery, lodash) {
alert("current page ::init called");
'use strict';
//Dependencies
var $ = jQuery,
_ = lodash;
//CONSTANTS
var PEOPLE_COLLECTION_NAME = 'people',
KEY_VALUE_COLLECTION_NAME = 'keyvalue',
INIT_FIRST_MSG = 'PERSISTENT_STORE_NOT_OPEN',
NAME_FIELD_EMPTY_MSG = 'Name field is empty',
AGE_FIELD_EMPTY_MSG = 'Age field is empty',
ID_FIELD_EMPTY_MSG = 'Id field is empty',
EMPTY_TABLE_MSG = 'No documents found',
DESTROY_MSG = 'Destroy finished succesfully',
INIT_MSG = 'Collection initialized',
ADD_MSG = 'Data added to the collection',
REPLACE_MSG = 'Document replaced succesfully, call find.',
REMOVE_MSG = 'Documents removed: ',
COUNT_MSG = 'Documents in the collection: ',
CLOSE_ALL_MSG = 'JSONStore closed',
REMOVE_COLLECTION_MSG = 'Removed all data in the collection',
LOAD_MSG = 'New documents loaded from adapter: ',
PUSH_MSG_FAILED = 'Could not push some docs, res: ',
PUSH_MSG = 'Push finished',
PASS_CHANGED_MSG = 'Password changed succesfully';
$('#init').click(initCollection);
$('#destroy').click(destroy);
$('#add-data').click(addData);
$('#find-name').click(findByName);
$('#find-age').click(findByAge);
$('#find-all').click(findAll);
$('#find-id-btn').click(findById);
$('#replace').click(replace);
$('#remove-id-btn').click(removeById);
//Log messages to the console and status field
var _logMessage = function (msg, id) {
//Get reference to the status field
var status = _.isUndefined(id) ? $('div#status-field') : $(id);
//Put message in the status div
status.text(msg);
//Log message to the console
WL.Logger.info(msg);
};
//Show JSONStore document in a table
var _showTable = function (arr) {
if (_.isArray(arr) && arr.length < 1) {
return _logMessage(EMPTY_TABLE_MSG);
}
//Log to the console
WL.Logger.ctx({stringify: true, pretty: true}).info(arr);
var
//Get reference to the status field
status = $('div#status-field'),
//Table HTML template
table = [
'<table id="user_table" >',
'<tr>',
'<td><b>_id</b></td>',
'<td><b>name</b></td>',
'<td><b>age</b></td>',
'<td><b>json</b></td>',
'</tr>',
'<% _.each(people, function(person) { %>',
'<tr>',
'<td> <%= person._id %> </td>',
'<td> <%= person.json.name %> </td>',
'<td><%= person.json.age %></td>',
'<td><%= JSON.stringify(person.json) %></td>',
'</tr>',
'<% }); %>',
'</table>'
].join(''),
//Populate the HTML template with content
html = _.template(table, {people : arr});
//Put the generated HTML table into the DOM
status.html(html);
};
//Scroll to the top every time a button is clicked
$('button').on('click', function () {
$('html, body').animate({scrollTop: 0}, 'slow');
});
function initCollection() {
console.log("init collection method called");
alert("init collection method called");
//Get references to the input fields DOM elements
var usernameField = $('input#init-username'),
passwordField = $('input#init-password');
//Get values from the input fields
var username = usernameField.val() || '',
password = passwordField.val() || '';
//Create the optional options object passed to init
var options = {};
//Check if a username was passed
if (username.length > 0) {
options.username = username;
}
//If if a password was passed
if (password.length > 0) {
options.password = password;
}
//JSONStore collections metadata
var collections = {};
//Define the 'people' collection and list the search fields
collections[PEOPLE_COLLECTION_NAME] = {
searchFields : {name: 'string', age: 'integer'},
//-- Start optional adapter metadata
adapter : {
name: 'people',
add: 'addPerson',
remove: 'removePerson',
replace: 'replacePerson',
load: {
procedure: 'getPeople',
params: [],
key: 'peopleList'
}
}
//-- End optional adapter metadata
};
//Define the 'keyvalue' collection and use additional search fields
collections[KEY_VALUE_COLLECTION_NAME] = {
searchFields : {},
additionalSearchFields : { key: 'string' }
};
//Initialize the people collection
WL.JSONStore.init(collections, options)
.then(function () {
_logMessage(INIT_MSG);
_callEnhanceToAddKeyValueMethods();
})
.fail(function (errorObject) {
_logMessage(errorObject.msg);
});
}
Thanks in advance
regards
V.H.C
I observed that underscore(loadash) templating was used. But nowhere I
found the reference given to the loadash. Also, I didn't find the
loadash file anywhere. can anyone please tell me how to do this?
You can build your own version of lodash or use underscore.
The version of lodash used by worklight is in the WL_ variable. Looking at your code, maybe you want to replace _ = lodash with _ = WL_. Alternatively when you bring your own version lodash or underscore it will be assigned to the _ variable automatically.
Alternatively, you can use other string template libraries like Handlebars.js or basic string interpolation by modifying the String prototype.