Blackberry WebWorks SMS Listener Exception - javascript

Specs:
WebWorks 2.2, Curve 9330 OS 6 Simulator and Device
We'll, I've tried just about everything and I can't figure this out. My application has a main page (index.html) and a background page (listener.html), as specified here:
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="1.0.0.0" rim:header="SimpleSMS">
<name>SimpleSMS</name>
<description>Simple SMS</description>
<content src="index.html">
<rim:background src="listener.html" runOnStartup="true" />
</content>
<rim:navigation mode="focus" />
<access subdomains="false" uri="http://jsconsole.com"/>
<feature id="blackberry.message.sms" />
<feature id="blackberry.app" />
<feature id="blackberry.io.dir" />
<feature id="blackberry.io.file" />
<feature id="blackberry.utils" />
</widget>
The listener.html looks like this:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="message_db2.js"></script>
<script type="text/javascript">
</script>
</head>
<body onload="initializeListener();">
</body>
</html>
The initializeListener() function is as follows:
function initializeListener() {
blackberry.message.sms.isListeningForMessage = true;
blackberry.message.sms.addReceiveListener(messageListener);
}
The issue:
When I install my app, and the listener starts running, my app can receive text messages without problems. As soon as I open the main application, the problems begin. If I just minimize the app to the background using the back or end button, the next sms received causes an exception. If I close the app through the menu, there's no exception, but the listener ceases to function. I have commented all code in messageListener and index.html does absolutely nothing but display some html. There is almost no documentation regarding having a background page. Does anyone have any ideas? Thanks in advance.

Could it be that webworks is going to these different pages and discarding everything that's in the previous page? (Like what happens to a form you fill out when you go to a new page in your browser)
Maybe you need to make use of Application Events to check when the app goes to the Foreground or Background; Maybe double check isListeningForMessage?
I'm thinking of something like
function onFG()
{
if (!blackberry.message.sms.isListeningForMessage)
{
blackberry.message.sms.isListeningForMessage = true;
blackberry.message.sms.addReceiveListener(messageListener);
}
}
blackberry.app.event.onForeground(onFG);
You can also make use of isForeground boolean if you need to have your code distinguish where it is running.

Related

calling actionscript 3 function from javascript with addCallback not working

I have a requirement in a project which has to call an actionscript 3 function from javascript. I read many answers from stackoverflow and adobe and have created a simple test application. In that, I have used ExternalInterface.addCallback to register both the functions and I've also included the security permissions in both actionscript and in html.
Action Script 3 Embedded code
I did not use an external .as file instead i used the action panel to create the code.
import fl.controls.Button
import flash.events.MouseEvent;
flash.system.Security.allowDomain("*")
var butt:Button = new Button();
addChild(butt);
butt.label = "hello";
butt.toggle = true;
butt.move(50, 50);
butt.height = 100;
butt.addEventListener(MouseEvent.CLICK, clickhandle);
function clickhandle(e:MouseEvent)
{
if(butt.height == 100)
butt.height = 200;
else butt.height = 100;
}
ExternalInterface.addCallback("callas", clickhandle);
The test app will display a ac3 button. Upon clicking that button it will toggle the expanding and collapsing of its height through a click handler 'clickhandle'. This is the function i am intended to call from javascript.
HTML Code
<html>
<head>
<script>
function callas() {
var hehe = document.getElementById('cvpanel');
console.log(hehe);
hehe.clickhandle();
}
</script>
</head>
<body>
<p>Test</p>
<object id='cvpanel' name='cvpanel' width="425" height="350" type="application/x-shockwave-flash" data="one.swf">
<param value="one.swf" name="movie">
<param name="allowscriptaccess" value="always"/>
<p>You need Flash to see it.</p>
</object>
</body>
</html>
The application runs under http://localhost through apache and all the files needed are in the same folder. I could run the application and could see the buttons appearing. By clicking it they toggle in height as expected.
When i call the function callas from browser console i get the error in console as
"TypeError: hehe.clickhandle is not a function"
in firefox and similar in Internet Explorer.
Is there anything missing?
In flash you're exposing clickhandle as callas
ExternalInterface.addCallback("callas", clickhandle);
so you're supposed to call callas() from javascript
var hehe = document.getElementById('cvpanel');
hehe.callas();

Visual Studio throwing exceptions when using Internet Explorer

Coding ASP.net web app with visual studio, i never had any problem when chrome or firefox is the default explorer. But when it's IE, a new project called Script documents suddently appear in my project explorer and visual studio always shows that exception in the new project for every pages load :
JavaScript execution error: Unable to get the property "tagName" of a null or undefined reference
Which doesn't prevent the web app to work, it's just annoying to have to click on the window in visual studio every time i switch pages while debuging.
The window offers me to Stop, Continue, or Ignore.
Ignore make the window reappear instantly, continue make it disapear for a little while...
Haven't found anything that solve it on google, neither in here.
How can this be solved ? And how is explorer so different ?
Edit :
Taking this as an exemple, i'm pretty sure it SHOULD work :
jQuery is not defined twitter bootstrap
And still, the window always pop-up in my IE 11, saying that it haven't foud the tagName property.
So now my new question is, do i have to specify the tag name of every object because i use boothstrap ? Or is it something else that cause the problem ?
EDIT :
This is the Master Page's codes :
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Canevas.master.cs" Inherits="MandatMobile.Canevas" %>
<%# Register Src="~/Controls/Menu.ascx" TagPrefix="ctrl" TagName="Menu" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"> </script>
<script type="text/javascript" src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<title></title>
<asp:ContentPlaceHolder ID="HeadContent" runat="server" >
</asp:ContentPlaceHolder>
</head>
<body>
<form runat="server" style="position:absolute; left:10px;">
<asp:Image runat="server" ImageUrl="~/Img/Fullogo.jpg" ></asp:Image>
<h2 style="position:absolute; top:-5px; left:120px; width:1200px;" >
<asp:ContentPlaceHolder ID="title" runat="server" >
</asp:ContentPlaceHolder>
</h2>
<%if (Convert.ToInt32(Session["Level"]) != 1)
{ %>
<div style="position:absolute; top:110px; left:0px;">
<ctrl:Menu ID="Menu1" runat="server" ></ctrl:Menu>
</div>
<% } %>
<br /><br /><br /><br />
<asp:ContentPlaceHolder ID="BodyContent" runat="server" >
</asp:ContentPlaceHolder>
</form>
</body>
</html>
SOLVED :
It was ridiculus... there was another menu before i build this one, what i did was put the previous menu in HTML comment and code my new menu on the same page, but the menu in comment was still up and even though it was in comment it was still looking for it's references, just like it WASEN'T in comment... What the... i think that is going to be my new question
Ok A lot of questions lets answer one by one:
"But when it's IE, a new project called Script documents suddently appear in my project explorer ..."
This project as you called, is a mechanism of visual studio that allows the developers debug javascript in the IDE (Visual Studio), but this only work for IE, because, as long as I know, there wasn't no interesting from Microsoft (or the browsers creators) to make it work for other browsers.
If you want to understand better what is it and how to use, enable, disable see this post: Using Visual Studio to Debug JavaScript in IE.
"...and visual studio always shows that exception in the new project for every pages load :"
As #Mithun Pattankar commented in your question, probably this exception occurs in other browsers too, but when you use chrome or firefox, you will get this exception more quietly. To see you have to go to DevTools (F12 in chrome) or some other custom tool, only then will see it.
But because you have the debug javascript in VS enabled, when you used the IE, the exception was thrown in VS instead of the browser.
And still, the window always pop-up in my IE 11, saying that it haven't foud the tagName property.
So now my new question is, do i have to specify the tag name of every object because i use boothstrap ?
Ok some misguidance here. First the problem isn't with the tagName property. Let me explain:
The message error that you got was "Unable to get the property "tagName" of a null or undefined reference". See the code bellow:
var v1 = { aGenericPropertyName: 10 };
v1.aGenericPropertyName = 20;
var v2 = v1.aGenericPropertyName;
v1 = null;
//or:
v1 = undefined;
var v3 = v1.aGenericPropertyName;
In the last line, depending on the browser, you may get this exception:
"Unable to get the property "aGenericPropertyName" of a null or undefined reference."
Did you get it now? The problem isn't the property, is the object that call the property or more accuracy the absence of an object (null or undefined) in a variable (in my sample code the variable v1).
Or is it something else that cause the problem ?
Well here's the real problem, because this kind of error can occur basically in any part of any javascript code that you added to the page. So it's not possible to solve this only by looking superficially.
I have some suggestions if you want to try. First, make sure you have the correct files of bootstrap.js and jquery.js and they are compatible between itself. Second check if this error is occurring in one of your custom javascript files.
Beyond that we will only be able to help you, if you post the exact line of the exception and how file the error occurs.

how to display a rally "custom board" dashboard in confluence wiki

I have been digging in the this site and others for several days and the answer to my problem still escapes me.
I have read all of these pages:
http://pastebin.com/cbagkw8h
but none of them exactly answers this question:
I am trying to get a Rally Dashboard (custom board) to appear in HTML/Javascript in a confluence wiki. I have gotten a simple Standard Report working using a read-only account and AppSDK1.32 with loginKey by embedding the following HTML/Javascript into the Confluence wiki page:
{html}
<meta name="Name" content="App Example: Rally Application" />
<meta name="Version" content="2011.04" />
<meta name="Vendor" content="Rally Software" />
<script type="text/javascript"
src="https://rally1.rallydev.com/apps/1.32/sdk.js?loginKey=loginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkey">
</script>
<script type="text/javascript">
function onLoad() {
var rallyDataSource = new rally.sdk.data.RallyDataSource(
'__WORKSPACE_OID__',
'__PROJECT_OID__',
'__PROJECT_SCOPING_UP__',
'__PROJECT_SCOPING_DOWN__');
rally.sdk.ui.AppHeader.destroy();
var reportConfig = {report: rally.sdk.ui.StandardReport.IterationBurndown,
width : 400, height: 300};
var report = new rally.sdk.ui.StandardReport(reportConfig);
report.display("reportDiv");
}
rally.addOnLoad(onLoad);
</script>
<div id="reportDiv" style="width: 400px; margin-left:20px"></div>
<br/>
{html}
I am trying to expand this success to an entire dashboard with App SDK2.x using the new apiKey - by using the following code:
{html}
<meta name="Name" content="App Example: Rally Application" />
<meta name="Version" content="2015.04" />
<meta name="Vendor" content="eBay Enterprise" />
<script type="text/javascript"
src="https://loginapirally1.rallydev.com/apps/1.32/sdk.js?loginKey=loginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkeyloginkey">
</script>
<script type="text/javascript">
function onLoad() {
rally.sdk.ui.AppHeader.destroy();
document.getElementById("iframeA").width = screen.width - 60 ;
document.getElementById("iframeA").height = (screen.width - 60 ) * 3;
}
rally.addOnLoad(onLoad);
</script>
<iframe id="iframeA" src="https://loginapirally1.rallydev.com/#/111111111d/custom/222222222?expandApp=333333333&apiKey=_apikeyapikeyapikeyapikeyapikeyapikeyapikey" width="1024" height="1024">
</iframe>
<br/>
{html}
I am noticing a few things:
1) it almost works - I get the dashboard/report title but not the cards
2) the apiKey seems to have no affect at all - I still get prompted for a login and password (which I could stand if I could see the cards).
3) it doesn't seem to matter if I put the apiKey before or after the hash symbol
Citation A suggested using the "full screen" dashboard/report but didn't cover the apiKey.
Citaton B says that the AppSDK2 uses the apiKey as of Apr 14 2014 but doesn't say how to use it exactly with AppSDK2.
I have gotten the apiKey to work with the Ruby API but it is unclear how to access the dashboard/reports from there.
Citation C says that the AppSDK1 is based on the Javascript dojo framework and the AppSDK2 is based on the Javascript Sencha's ExtJS but avoids giving any kind of rosetta stone from one to the other.
The only other options I can think of is to 1) copy the entire HTML page-source from the "Custom Board" and then start debugging the Javascript with ExtJS (but I cannot find an example of where to put the apiKey for ExtJS) or 2) bypass all of the APIs and use Ruby Watir-Webdriver (which uses
Selenium) and VNCServer to clip an image of the "Custom Board" page and show THAT in confluence.
Citations: http://pastebin.com/YMUEPjSF
The issue seems to be specific to the canned Custom Board that cannot be loaded externally. It should work if you write a js source code to build a similar Board and compile that into a deployment html. That is similar to option (1) you mentioned in the end of your post if I understand it correctly.
Here is my test where I compared Custom Board and Custom HTML side by side.
Below is a screenshot from Rally. This custom dashboard has Custom Board on the left and Custom HTML on the right. The Custom HTML is using a code example of filterable board from AppSDK2 documentation.
Next I use this code:
<html>
<head>
<title>Custom Grid</title>
<meta name="Name" content="App: Custom Dashboard"/>
<meta name="Version" content="2011.08.31"/>
<meta name="Vendor" content="Rally Labs, NickM"/>
<script type="text/javascript" src="https://rally1.rallydev.com/apps/1.32/sdk.js?loginKey=c33e83...."></script>
<script type="text/javascript">
rally.addOnLoad(function() {
var iframe = document.createElement("iframe");
iframe.src = "https://loginapirally1.rallydev.com/#/14018981229/custom/34207853894"
iframe.width = 2000;
iframe.height = 1000;
document.getElementById("storyboard").appendChild(iframe);
});
</script>
</head>
<body>
<div id="storyboard"></div>
</body>
</html>
Here is the dashboard loaded externally on localhost:3000. The left column of the dashboard where Custom Board is expected to load is empty, but the right column with a custom html code of a board loads successfully:
It looks like the canned Custom Board cannot be loaded externally but a custom html code written in AppSDK2 can be displayed externally.
A couple of observations:
There is really no upgrade path from AppSDK1 to AppSDK2. The underlying frameworks and the class structures are very different and the code cannot be simply refactored. There is no translation from one to the other.
LoginKey is intended to work with AppSDK1. Both are legacy. Both predate AppSDK2 and ApiKey. To use ApiKey with custom html apps written with AppSDK2 see "Use API Key with AppSDK2" article.
AppSDK2 does not support LoginKey usage for authentication. The reason it seems to work in this example is that we load the entire page. Loading the entire page using iframe's src property is possible with LoginKey. In this example there is no reason to use ApiKey and LoginKey together. You are right that ApiKey makes no difference in this use case.
The way LoginKey works is that it "tricks" the browser into thinking that there is this different server, loginapirally1.rallydev.com. If you look in Network tab of your browser and see that request comes from there it means that LoginKey is working. ApiKey works differently. There is no equivalent to loginapirally1 server with ApiKey.
If you are being prompted to supply login credentials when using LoginKey it means that LoginKey is not working. See "LoginKey Troublshooting" article.
Embedding custom AppSDK2 apps in 3rd party portals (running custom apps externally) is possible with ApiKey, and the supported scenario described in this guide is similar to the option (1) you mentioned in the end of your post. Loading entire Rally page or entire Rallynavigation is not a supported use case even though it is possible with LoginKey.

How to stop reloading of Javascript

I have an issue with Javascript reloading due to Tiles.
Tiles-definition.xml
<tiles-definitions>
<definition name="template-main" template="/WEB-INF/jsp/home.jsp">
<put-attribute name="header-main-content" value="/WEB-INF/jsp/header_main.jsp"/>
<put-attribute name="header-quote-content" value="/WEB-INF/jsp/header_quote.jsp" />
<put-attribute name="menu-content" value="/WEB-INF/jsp/menu.jsp" />
<put-attribute name="body-content" value="/WEB-INF/jsp/slides.jsp" />
<put-attribute name="footer-content" value="/WEB-INF/jsp/footer.jsp" />
</definition>
<definition name="template-main-login" extends="template-main">
<put-attribute name="header-main-content" value="/WEB-INF/jsp/header_main.jsp" />
</definition>
</tiles-definitions>
home.jsp
<body style="background-color: #5F9EA0">
<head>
<script src="<c:url value="/resources/js/jquery-1.11.1.js" />"></script>
<script src="<c:url value="/resources/js/example.js" />"></script>
bla bla ..
example.js
$(document).ready(function() {
setTimeout(function () {
popUp('show');
}, 1000);
});
I am using Spring-MVC:
When the application is loaded I am returning the view as template-main. So the first template definition is called and the application is opened with a login popup as I am calling the popup on document load.
Problem:
Now when I give the login credentials and submit I am calling template-main-login which in turn is extending the template-main. Now the problem is, the Javascript which I have included in the home.jsp is loading again (may be since I am extending the template-main layout) such that I am getting the popup opened for the second time which I want to stop.
So please let me know how to stop the popup opening again.
i would suggest rather than making home.jsp as your template make a separate jsp only for your template and basetemplate will have generic things like loading external js and css files and keep specific js code in specific jsp
You need to ensure that your JS files have the proper cache control/expires headers (either set a long date or use ETags). If you use ETags, the static files will still query the server implementation to check if the file hash has changed or not. You can avoid that by using expires headers on all your static files so that the browser can cache them and load them from the local computing device as opposed to sending in a HTTP request to your server.

WYSIWYG editor in asp.net page error

I am using an open source wysiwyg editor on one of my asp.net web pages to create news pages... On one page It is put into place like this:
Registered at top of asp.net web page...
<%# Register Src="~/WebUserControls/HTMLEditorControl.ascx" TagName="HTMLEditorControl" TagPrefix="uc2" %>
Incorporated into the page:
<div>
<uc2:HTMLEditorControl ID="HelpTextBox" runat="server" />
</div>
In the code behind there is a Save method that basically saves the above editor data using the id:
dataset.column = htmlTextArea.GetHTML ;
When I try to bring up the page with the editor, I get the error: 'WYSIWYG' is undefined at Line 900, which is:
<script language="javascript" type="text/javascript" >
WYSIWYG.attach('ctl00_ContentPlaceHolder_HelpTextBox_htmlTextArea');
</script>
What's confusing, I have another page set up identically, that produces the same WYSIWYG.attach source, but it handles it with no problem at all. The only difference is the names of the pages. The page that works produces the following, with no problem:
<script language="javascript" type="text/javascript" >
WYSIWYG.attach('ctl00_ContentPlaceHolder_htmlTextArea_htmlTextArea');
</script>
So I'm at a loss...
Does the name of your code-behind class match the class name of your aspx page? Does the aspx page point to the correct code behind file?
My guess is that you copied and pasted but forgot to change that.

Categories