[TIMOB-8732] Android: Custom JavaScript objects sent in events to a WebView throw errors
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2012-05-15T11:50:35.000+0000 |
Affected Version/s | Release 2.0.0, Release 1.8.2 |
Fix Version/s | n/a |
Components | Android |
Labels | api |
Reporter | Devang Gandhi |
Assignee | Josh Roesslein |
Created | 2012-04-13T17:47:43.000+0000 |
Updated | 2017-03-10T19:14:07.000+0000 |
Description
When JavaScript objects are accessed from webview, ljava.lang.object error is thrown. Javascript objects are defined in a js file, which is then passed to html page using fireevent. The values are retrieved correctly in iOS.
snippet of JS file:
var win = Ti.UI.currentWindow;
var activity_obj = {
screen_name: [],
idea_title : []
};
activity_obj.screen_name[0] = 'bhushan';
activity_obj.screen_name[1] = 'bhaskar';
activity_obj.screen_name[2] = 'deore';
activity_obj.idea_title[0] = 'android';
activity_obj.idea_title[1] = 'iphone';
activity_obj.idea_title[2] = 'app';
var webView = Ti.UI.createWebView({
url:'webview_logging.html',
height:400
});
win.add(webView);
webView.addEventListener('load', function(e) {
Ti.App.fireEvent('data', activity_obj);
});
Snippet of html file:
<html>
<head>
<title>Webview Logging</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
function show_content(e) {
//alert('in event');
for (var prop in e) {
if (e.hasOwnProperty(prop)) {
var obj_01 = e[prop];
Ti.API.info("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
Ti.API.info(JSON.stringify(obj_01));
}
}
}
Ti.App.addEventListener('data', show_content);
</script>
</head>
<body>
<div id = 'add_content'>
ド標準第5版の刊行を大いに
</div>
</body>
</html>
Also attached crash log, and other js files, as a complete project.
Steps to reproduce: Below are attached app.js and other files. Create a new project in titanium.create source folder under resources, and place all files excluding app.js. replace app.js with attached app.js.
Run the project, and see the console.
Attachments
File | Date | Size |
---|---|---|
app.js | 2012-04-13T17:47:44.000+0000 | 421 |
log.txt | 2012-04-13T17:47:43.000+0000 | 47676 |
webview_logging.html | 2012-04-13T17:47:43.000+0000 | 602 |
webview_repaint.js | 2012-04-13T17:47:43.000+0000 | 526 |
webview.js | 2012-04-13T17:47:43.000+0000 | 1005 |
xml2json.js | 2012-04-13T17:47:44.000+0000 | 889 |
This looks to be a duplicate of TIMOB-8308. Ran test case on latest master (2.1) CI and works fine.
Closing ticket as duplicate.