having problem in blackberry - blackberry

I am doing coding from beggining blackberry by Anthony Rizk.
I am stuck with this code as it is showing error again and again...
private void getURL() {
HttpRequestDispatcher dispatcher = new HttpRequestDispatcher(urlField.getText(),
"GET", this);
dispatcher.start();
}
Can anyone explain me why we are passing this as parameter and why actually this code is doing...

"this" refers to the main screen you passed to the class so you can alert the requestFailed string. Check the run method on page 170. You'll see screen.requestFailed("Unexpected...").
As for your error - I suggest adding this line:
System.out.println(" ----------------- HTTPREQUESTDISPATCHER ---------- " + urlField.getText());
right before your dispatcher.start(); line and then compile in debug mode to see what your console says. Just to make sure your URL to request is a valid web URL.
Additionally, make sure your simulator has MDS enabled. You need that to make web calls.
In eclipse it is under Run->run configurations-> simulator tab -> general -> checkbox for Mobile Data System.
I don't know where it is in the RIM package. If you're not using eclipse, you might want to switch over to it. It will highlight errors and try to help you resolve them.

Related

In a Firefox extension, if I open a tab using a custom scheme, how do I close it, because my extension is not authorized for that scheme pattern?

I have a custom scheme mapped on my Windows machine: "dbn".
So, when I put dbn:/some/arguments in the Firefox address bar (or click on such a link), it launches in another application. This works great.
However, in a Firefox extension, I don't know how to "call" or "activate" this custom scheme except by opening a new tab, like this:
browser.tabs.create({ url: 'dbn:/some/arguments' });
That works fine, except now I have an open tab with dbn:/some/arguments as the URL. I have attempted to subsequently close it from my extension, but I can't because:
Error: Missing host permission for the tab
My extension doesn't have permissions for that "host."
I have tried to give it permissions via a match_patterns value of dbn:* but that throws an error when I try to reload the extension because those values apparently have to use one of the expected schemes (http, https, ftp, etc.).
I end up just having to close the tab manually, which isn't terrible, but is clearly sub-optimal.
So, two questions:
Is it possible to "call" a URL in such a way to activate a custom-mapped scheme on Windows without opening a tab? The only way I could think of doing this in such a way that it would activate my mapped command was to open a tab, but are there other ways?
If opening a new tab is the only way to do this, how do I close the tab I just opened without having the permissions problem I mention above?
Update
I don't think it's permissions anymore. The Promise simply won't resolve.
browser.tabs.create({ url: "some/url" })
.then(tab => console.error("I never get here"));
I've debugged up, down, and sideways. The new tab opens, and I can write to the log all around that operation, but the code in then just doesn't execute, no matter what I put in there. I tried to trap an error with try...catch, but that didn't trap anything.
I now think that permission above was coming from a different extension, not my extension. I don't think this has anything to do with the host.
AFA custom schemes, there is an open bug: Extend match patterns to handle custom protocol schemes
You can tabs.remove() a tab by its ID which you get from tabs.create().
async function fun() {
// note this is async
const tab = await browser.tabs.create({url: 'dbn:/some/arguments'});
// later remove it
browser.tabs.remove(tab.id);
}
// or
browser.tabs.create({url: 'dbn:/some/arguments'})
.then(tab => {
// do what is needed
// later remove it
browser.tabs.remove(tab.id);
});
Update:
Regarding the Promise, there is not enough information to pinpoint the issue.
Which permissions have been set?
Where is the code running?
Use catch to get more info about the Promise failure:
browser.tabs.create({url: "some/url"})
.then(tab => console.log(`Created new tab: ${tab.id}`))
.catch(error => console.log(error.message));

Response isn't a type, cannot and expected to find ';'

I'm trying to send a post request within dart with the following code.
Future<Response> post (url,
{
headers, // My Map<String, String> for header info
body // My Map<String, String> for body info
})
return JSON.jsonDecode(post);
I expect it to send, however, I get two errors.
The name response isn't a type, and cant be used as a type argument, when I hover over "Response" and
expected to find ;, when I hover over "post".
I also get green underlining in android studio saying avoid unnecessary statements
This problem happens in Computers with low specs which makes android studio take time to recognize new input. Waiting will fix the issue, and you can speed this "recognition" process by clicking on the type Response in you case which will make the editor focus on it. And also add parenthesis and commas in correct way before adding new code as Dart Analyzer will quickly get confused and fill your editor with error messages.
I encountered the same issue, and I found that rerunning flutter pub get helped as that command makes sure the Http library gets downloaded.

Firefox native messaging through webextension

Created a webextension for firefox (currently using Nightly 52), that uses native messaging to launch a java program on Linux (Ubuntu 14, 32x).
The webextension loads, reads the .json file and reads the path which points to a script that starts the java program. The JSON and the path are correct as when I use:
var native = browser.runtime.connectNative("passwordmanager");
console.log("native.name" + native.name); //outputs passwordmanager.
native.onDisconnect.addListener(function(m) { console.log("Disconnected"); });
The above code prints the name of the native port and also prints "Disconnected". So I m guessing the native app is terminating for some reason.
The application is only skeleton right now, that just does sysout and reads sysin and works correctly if Launch it directly through the shell script.
While debugging the webextension, I am not able to step into the call to connectNative, as it just steps-over that call instead of doing step-in. So kind of out of options whats' going wrong.
Please let me know if anyone is able to create a native messaging app based on FF webextension and any pointers on what I might be doing wrong.
Thanks
This solution here shows you how to detect onConnect and onFail. It should help you out to figure out your real problem.
So I don't think you can do proper error handling with connectNative from the JS side alone. You can do somewhat error handling if you get the exe side involved, but you can't get a string for "error reason" when an error occurs. The error is only logged to console.
First make sure to set your deeloper prefs, so messages show in your browser console. You can use this addon - https://addons.mozilla.org/en-US/firefox/addon/devprefs/ - or read that addon description it gives you the MDN page with the prefs to set.
Then this is how you can do some sort of error handling (without error reason) (pseudo-code - i might need a .bind in the callbcks):
function connectNative(aAppName, onConnect, onFail) {
var listener = function(payload) {
if (!connected) {
connected = true;
port.onDisconnect.removeListener(failedConnect);
onConnect();
} else {
// process messages
}
}
var failedConnect = function() {
onFail('failed for unattainable reason - however see browser console as it got logged there');
}
var connected = false;
var port = chrome.runtime.connectNative(aAppName);
port.onMessage.addListener(listener);
port.onDisconnect.addListener(failedConnect);
return port;
}
Now in your exe, as soon as it starts up, make it write to stdout something. That will trigger the onConnect.

Unable to findByXpath using Leadfoot / Intern

Using Intern JS with WebDirver to communicate with Appium 1.4.1, I have a simple functional test, part of which should find a text input box on the login screen of our iOS app, tap into it and type the user's login name:
define([
'intern!object',
'intern/chai!assert',
'require'
], function (registerSuite, assert, require) {
registerSuite({
name: 'Suite Name',
'Login Screen': function () {
return this.remote
.setFindTimeout(50000)
.findByXpath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/UIATextField[1]")
.tap()
.type('student1#demo.com')
.end()
.then(function (pagetitle) {
assert.strictEqual(pagetitle, 'DEMO COLLEGE',
'Should land on app dashboard with school title displayed');
});
}
});
});
When executed using intern-runner everything appears to go well, Appium launches our app and awaits my input - but no matter what I try I can't find the element I need to type into using Leadfoot's findByXpath:
$ intern-runner config=tests/appium
Listening on 0.0.0.0:9000
Starting tunnel...
Initialised iOS on MAC 8.1
Test main - Suite Name - Login Screen FAILED on iOS on MAC 8.1:
NoSuchElement: [POST http://[appium-server-address]:4723/wd/hub/session/80e20453-452e-4181-8713-4f9e0cfa427f/element / {"using":"xpath","value":"//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/UIATextField[1]"}] An element could not be located on the page using the given search parameters.
at Server._post <../../.nvm/v0.10.35/lib/node_modules/intern/node_modules/leadfoot/Server.js:68:9>
Using Appium's GUI "inspector" I've confirmed the Xpath to the text-input-box element is:
"//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/UIATextField[1]"
Can anyone suggest where I'm going wrong please?
Looks like the Appium Inspector tool on my Mac was duplicating part of the path?
.findByXPath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/**UIATextField[1]**")
.type("wibble")
Remove the duplicated element in bold (the final UIATextField[1]) ....
.findByXPath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/**UIATextField[1]**")
.type("wibble")
And it works.
Thanks Appium Inspector. Thanks a lot.

SmartGWT throws JavaScriptException: (null): null

When using GWT 2.0.x and SmartGWT 2.2
Code as simple as:
public class SmartGwtTest implements EntryPoint {
public void onModuleLoad() {
IButton button = new IButton("say hello");
}
}
will generate the exception.
com.google.gwt.core.client.JavaScriptException: (null):
This only happens in hosted (devmode)
ant hosted
I also suspect that maybe the GWT Development Plugin might have something to do with it.
Have you found a similar problem? How did you solve it?
Not an answer but a workaround was to use compile the app.
And use it that way.
ant build
Although compilation takes a long time because it generates several permutations of the code. ie different versions for different browser to make compilation faster you can set your target browser while testing.
to do that in your ModuleName.gwt.xml file add the following line:
<set-property name="user.agent" value="gecko"/>
<!-- to test with firefox -->
That will make compilation faster.
Hope this helps someone.
OK, so I was getting this in Firefox in hosted mode and it turned out that a widget was set to have width100 but there was not enough room on the screen to render the widget (my browser was not maximized).
I think this resulted in a negative width being set and this ambiguous Javascript exception was thrown as a result. Maximizing the browser alleviated the issue, you might want to try setting a width to begin with and using resize handlers to render your widget properly.

Resources