Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Contributor
Posts: 5
Registered: ‎05-22-2012
My Device: Developer
My Carrier: Developer
Accepted Solution

Implement custom Phonegap/WebWork application

Hello!

 

I was developing Blackberry java application based on BrowserField but now I found that Phonegap will be better solution. However my app requared custom login screen and some other functionality. As I understand login screen implemented in WebWork, so my question is what I need to customize Phonegap/WebWork application? Can I use port Phonegap code to work with BrowserField or can I customize WebWork and rebuild it?

 

Any help would be very appreciated!

BlackBerry Development Advisor
Posts: 669
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: Implement custom Phonegap/WebWork application

If you're going the Phonegap route, head over to https://github.com/phonegap/phonegap-plugins/tree/master/BlackBerry/ChildBrowser .  The childbrowser plugin is likely what you're looking for.  I use it in my projects, and it's great.

New Contributor
Posts: 5
Registered: ‎05-22-2012
My Device: Developer
My Carrier: Developer

Re: Implement custom Phonegap/WebWork application

Hi. Thanks for reply, but I'm afraid it definitely isn't what I'm looking for. As I understand childbrowser allows to create a separate window with browserfield to load external web page and I can't use Phonegap functionality inside this window. But what I'm looking is way to customize login screen in Phonegap+WebWork. My web app requests several url and I want is that user doesn't need to put credentials for every resource. I want separate logging screen for all app and than credentials from this login screen will be used for any resource.

 

I found that Phonagap can work without WebWork. I got sources from Cordova git and than created custom BrowserFieldListener similar to how it is implemented in WebWork:



public class ContainerBrowserFieldListener extends BrowserFieldListener {

private ScriptEngine _scriptEngine = null;

public ContainerBrowserFieldListener() {
}

/**
* @see net.rim.device.api.browser.field2.BrowserFieldListener
*/
public void documentCreated( BrowserField browserField, ScriptEngine scriptEngine, Document document ) throws Exception {

_scriptEngine = scriptEngine;

try {
CordovaExtension cordovaExtension = new CordovaExtension();
cordovaExtension.loadFeature(cordovaExtension.getFeatureList()[0], "2.3.3", document, scriptEngine);
} catch( Exception x ) {
Logger.err("Can't load Cordove", x);
}

}

/**
* @see net.rim.device.api.browser.field2.BrowserFieldListener
*/
public void documentLoaded( BrowserField browserField, Document document ) throws Exception {

if( _scriptEngine != null ) {
// Inform the js framework that we are ready to process requests
try {
_scriptEngine.executeScript( "try { var event = document.createEvent(\"Event\"); "
+ " event.initEvent(\"frameworkready\", true, true); "
+ " window.dispatchEvent(event); } catch (e) { } ", null );
} catch( Exception e ) {
}
}

}

}

 

But I'm not sure about how stable is that solution. Maybe it would be better to try to customize WebWork code.

BlackBerry Development Advisor
Posts: 846
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: Implement custom Phonegap/WebWork application

I'm not really following what you need to do. Why do you feel you need to customize the Browserfield implementation in PhoneGap?

 

If you need to capture login information for multiple sources, why not create your screen in HTML? The ChildBrowser extension would allow you to use OAuth to access 3rd party sites like Twitter, FourSquare, etc, without storing the user's credentials for that site. Highly recommended.

 

If you are going to do an app that is essentially a Browserfield, there's almost no reason why you would do it in Java and many reasons to use PhoneGap/WebWorks. PhoneGap is a cross platform way of packaging applications that use a native Browser view as the UI. For BlackBerry, PhoneGap just calls the WebWorks compiler, so regardless it's the same approach.

 

 

Tim Windsor
Open Source Technical Lead
New Contributor
Posts: 5
Registered: ‎05-22-2012
My Device: Developer
My Carrier: Developer

Re: Implement custom Phonegap/WebWork application

Thanks, but I'll try to explain again what is the problem. We have online JQueryMobile (JQM) application that is hosted on IIS server with NTLM authentification. Our JQM performs a set of AJAX requests to several REST services that also use NTLM auth. So when I use standard WebWork+Phonegap I get a set of auth requests to input credentials. But we want have a same credentials for all requests. We want have one login screen for all and this must be separate screen that user see at startup. I found that all this functionality is embeded (hardcoded) in WebWork. So I decide rewrite some code in WebWork and use it to build custom Phonegap application. I found that code what I need is placed into foder device-template in WebWork SDK folder while building WebWork app. All that I need is to replace it and build Phonegap app.

Highlighted
BlackBerry Development Advisor
Posts: 846
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: Implement custom Phonegap/WebWork application

Okay, everything's open source so you should be able to do what you need, but I don't know how much we will be able to help you with it.

Tim Windsor
Open Source Technical Lead
New Contributor
Posts: 5
Registered: ‎05-22-2012
My Device: Developer
My Carrier: Developer

Re: Implement custom Phonegap/WebWork application

Thanks, Tim. I have already implemented features that I need.