IBM worklight - Call worklight adapter from another html file - ibm-mobilefirst

i've created another file testW.html beside main file and i've try to call worklight adapter in that file but it isn't work:
Here is my testW.html:
<html>
<head>
<script>window.$ = window.jQuery = WLJQ;</script>
<script type="text/javascript" data-dojo-config="isDebug: false, async: true, parseOnLoad: true, mblHideAddressBar: false" src="dojo/dojo.js"></script>
</head>
<body onload="WL.Client.init({})">
<h1>Hello</h1>
<button type="button" onclick="LoginWS();">Click Me!</button>
<script src="js/PushAppRealmChallengeHandler.js"></script>
<script src="js/initOptions.js"></script>
<script src="js/test2.js"></script>
<script src="js/configFb.js"></script>
<script src="js/messages.js"></script>
</body>
</html>
In here, LoginWS() is function call worklight adapter in test2.js,i've try call it in test2.html every thing is ok,how i call it in testW.html ?

IBM Worklight applications are single page applications, however that doesn't mean you can't use HTML from other files. Take a look at the Building a multi-page application getting started module and the associated sample code.
Related questions:
IBM Worklight Using Multiple HTML Files
type error: cannot call method 'invoke procedure' of undefined in worklight
How to pass data between pages through worklight client API

Related

angularjs routing is not working no error found

what seems to be wrong here i dont get any error but at the same time no progress in routing. .
index.html
<!DOCTYPE html>
<html>
<head>
<title>My Angular App</title>
<link rel="stylesheet" type="text/css" href="/myAngularApp/css/style.css">
<link rel="stylesheet" type="text/css" href="/myAngularApp/css/bootstrap/css/bootstrap.min.css">
<script type="text/javascript" src="/myAngularApp/css/angular/angular.min.js"></script>
<script src="/myAngularApp/css/mainpage.js"></script>
<script type="text/javascript" src="/myAngularApp/css/angular/angular-animate.min.js"></script>
<script type="text/javascript" src="/myAngularApp/css/angular/angular-resource.min.js"></script>
<script type="text/javascript" src="/myAngularApp/css/angular/angular-route.min.js"></script>
<script type="text/javascript" src="/myAngularApp/css/bootstrap/ui-bootstrap-tpls-2.2.0.min.js"></script>
</head>
<body ng-app="myApp">
<h1> this is index.html </h1>
<div ng-view></div>
</body>
</html>
mainpage.js // where my controller is
var app = angular.module('myApp', ['ngRoute', 'ngAnimate', 'ngResource', 'ui.bootstrap']);
app.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl : 'index.html'
})
.when('/home', {
templateUrl : 'homepage.html'
})
.otherwise({
templateUrl : 'index.html'
});
});
when i load '/' in my browser nothins is happening same with /home i dont know where did i get wrong since there is no error in my console
The template for a route should be a partial view. Here index.html is the root of the single page app , this page should never reload (unless you want to destroy and rebootstrap the app). Try changing the templateUrl for / to a file that just has <h2> HELLO WORLD!</h2> and monitor the console (dev tools) for any 404 errors related to fetching the template
I think problem is with your javascript file name. In index you mentioned mainpage.js and in description its homepage.js.
Edit : Okay. Then try arranging files list like
<script type="text/javascript" src="/myAngularApp/css/angular/angular.min.js"></script>
<script type="text/javascript" src="/myAngularApp/css/angular/angular-animate.min.js"></script>
<script type="text/javascript" src="/myAngularApp/css/angular/angular-resource.min.js"></script>
<script type="text/javascript" src="/myAngularApp/css/angular/angular-route.min.js"></script>
<script type="text/javascript" src="/myAngularApp/css/bootstrap/ui-bootstrap-tpls-2.2.0.min.js"></script>
<script src="/myAngularApp/css/mainpage.js"></script>
As mentioned in the answer by user Priyanka, the filename can be the issue. But that should produce an error on the console and according to you there was no error on the console.
The other possible reason can be the sequence in which you've imported your files. I generally sequence my files this way -
<head>
<!-- 1. External CSS Libraries likes bootstrap, jquery -->
<!-- 2. My Application specific CSS files -->
<!-- 3. External JS libraries like Angular, bootstrap, JQuery -->
<!-- 4. My Application specific JS files like my controllers, services, directives etc.
</head>
Again the sequence in which you import the external JS libraries may also cause problems.

Polymer in ASP.net 5

Trying to make a custom polymer element in ASP.NET 5 in Visual Studio Community. I select "New Project"->"Web"->ASP.NET Core Web Application (.NET Core). In Solution Explorer I add a new file "helloworld.html", in this file I create a new polymer element with this code:
<link rel="import" href="https://polygit.org/components/polymer/polymer.html">
<dom-module id="hello-world">
<style></style>
<template>
<h1>Hello world</h1>
</template>
</dom-module>
<script>
Polymer({
is: "hello-world"
});
</script>
Next I try to implement (add) this element to the DOM that is created by ASP.NET 5, so I make changes in those two files index.cshtml and _layout.cshtml.
The file index.cshtml is:
#{
ViewData["Title"] = "Home Page";
}
<link rel="import" href="~/helloworld.html"/>
<div class="row">
<hello-world></hello-world>
</div>
In _layout.cshtml I add two lines of code:
<link rel="import" href="https://polygit.org/components/polymer/polymer.html">
<script src="https://polygit.org/components/webcomponentsjs/webcomponents-lite.js"></script>
Next I click debug but no Hello World on the screen. Only header and footer from _layout.cshtml
I think
<link rel="import" href="~/helloworld.html"/>
must be outside the { ... }
If not, take a look at the source HTML code and, using F12 (IE/Chrome... debugger), see Network tab for errors.
In addition to what already has been suggested. Are you sure that
<link rel="import" href="https://polygit.org/components/polymer/polymer.html">
<script src="https://polygit.org/components/webcomponentsjs/webcomponents-lite.js"></script>
are in the right place? Load the page, open the developer tools (F12) and in the HTML/DOM view/explorer check that these lines actually appear in the <head> tag of the loaded page. The default ASP.NET Core template contains <environment> tags in _Layout.cshtml. In my test with your code I first put the links into the wrong environment. Now it works for me.

IBM Worklight 6.1 - Previewing a Dojo hybrid app displays a blank page

I am developing a Hybrid application in Worklight 6.1 using Dojo 1.9.3. As a startup i just created a simple project with a View and a scrollable view.
Index.html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>index</title>
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="shortcut icon" href="images/favicon.png">
<link rel="apple-touch-icon" href="images/apple-touch-icon.png">
<link rel="stylesheet" href="css/main.css">
<script>window.$ = window.jQuery = WLJQ;</script>
<script type="text/javascript" data-dojo-config="isDebug: false, async: true, parseOnLoad: true, mblHideAddressBar: false" src="dojo/dojo.js"></script>
</head>
<body style="display: none;">
<div data-dojo-type="dojox.mobile.View" id="mainView"
data-dojo-props="selected:true" style="background-image: url('images/bgnew.jpg'); background-repeat: repeat;">
<div data-dojo-type="dojox.mobile.ScrollableView" id="view1"
data-dojo-props="selected:true,scrollDir:'v'">
<div data-dojo-type="dojox.mobile.Heading"
data-dojo-props="label:'Login',fixed:'top'">
</div>
</div>
</div>
<script src="js/initOptions.js"></script>
<script src="js/main.js"></script>
<script src="js/messages.js"></script>
</body>
</html>
After creating building and deploying the project i tried to Run it by clicking "Preview as Common Resources" link. But unfortunately nothing displays on my screen. I checked my browser console i can see no error showing.
Dojo is already present in my www folder.
How to solve this issue.
Any help is appreciated.
Cannot reproduce. I've done the following in Worklight 6.1.0.0:
Created a new Worklight project
Added an application with the Dojo library (using the provided wizard)
Right-click on the Common folder > Run As > Preview
The browser opened, displaying the app.
The same worked if opening Worklight Console and selecting Preview as Common Resources.
Tested on OS X 10.9.2
Chrome as default external browser (Eclipse > Preferences > General Web Browser > use external web browser)
It happened to me today, and I found a solution :
Use the default Dojo provided by the IBM Worklight (actually the 1.9.1 ) instead of the 1.9.3
When I tried to import and use the 1.9.3, it did the same thing than the original poster. I think it is not already supported or there is a problem we do not think about during the importation.

dojo.ready call shows error in Worklight 6.0

I have created a dojo based Worklight project and a hybrid application it.
I did a drag and drop of a dojo mobile button which gets added inside a dojo mobile view. All of this works fine and renders fine in the various environments (common, android etc.). It also correctly shows the look and feel in Rich Page Editor.
But then i added a script that has a very simple dojo.ready call. Now when i run this application i get a console error saying ReferenceError: dojo is not defined. Any idea why that is happening?
I know that i have correctly setup the dojo as other pieces seem to work. I have also checked that the dojo.js is loading (which is obvious as the other pieces are working). I am using IBM Worklight 6.0 developer edition with all capabilities installed.
Here is my sample code
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>jmdwl</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="shortcut icon" href="images/favicon.png">
<link rel="apple-touch-icon" href="images/apple-touch-icon.png">
<link rel="stylesheet" href="css/jmdwl.css">
<script>window.$ = window.jQuery = WLJQ;</script>
<script type="text/javascript" src="dojox/mobile/deviceTheme.js"></script>
<script type="text/javascript" data-dojo-config="isDebug: false, async: true, parseOnLoad: true, mblHideAddressBar: false" src="dojo/dojo.js"></script>
<script>
dojo.ready(function() {
alert("Here");
});
</script>
</head>
<body id="content" style="display: none;">
<div data-dojo-type="dojox.mobile.ScrollableView" id="view0" data-dojo-props="selected:true">
<!--application UI goes here-->
<button data-dojo-type="dojox.mobile.Button">Label</button>
</div>
<script src="js/initOptions.js"></script>
<script src="js/jmdwl.js"></script>
<script src="js/messages.js"></script>
</body>
</html>
Thanks,
Gaurav
If you want to use dojo.ready you must initialize it first.
<script>
require(["dojo/ready"], function(ready){
ready(function() {
alert("Here");
});
});
Here's the reference : http://dojotoolkit.org/reference-guide/1.8/dojo/ready.html#dojo-ready
Update 1
Which Version of dojo do you use by now? 1.6 or 1.7+ ?
The new AMD requires to initialize the modules like i write before.
Have you read this threads? There seem to be an failure while importing the dojo Libarys. I guess this could have something to do with your error.
worklight fail to require DOJO Combobx on real device -fail to load ... /dijit/form/nls/it/ComboBox.js
and
Worklight core-web-layer.js errors
Regards, Miriam

Loading jQuery from Google into an Air project

I'm using Aptana Studio with the following source code:
<html>
<head>
<title>New Adobe AIR Project</title>
<script type="text/javascript" src="lib/air/AIRAliases.js"></script>
<script type="text/javascript" src="lib/air/AIRIntrospector.js"></script>
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("jquery", "1");
</script>
<script>
$(function() {
alert('ok');
})
</script>
</head>
<body>
</body>
</html>
This works if I just pull up the page as an html page.
But why am I getting
ReferenceError: Can't find variable: google.
ReferenceError: Can't find variable: $
When I use Aptana's Run command, or even if I build the application into an .air file and run it from Window's explorer.
You cannot load external JS files using the tag in an AIR application. It violates the AIR security stuff.
You MUST load js files from the application sandbox.
http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7f0e.html#WS5b3ccc516d4fbf351e63e3d118666ade46-7ef7