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

Java Development

Reply
New Contributor
Posts: 7
Registered: ‎12-28-2010
My Device: BB Torch
My Carrier: At&t

Using BrowserFieldController & ProtocolController to intercept clicks

Hi,

 

I am trying to intercept user clicks on a BrowserField.

 1. I would like to open some given url patterns in BB external Browser application. (Done)

 2. For unmatched patterns, will continue using the BrowserField instance. (not working)

 

This is how I intercepted user requests:

 

Class A:

 

MyBrowserFieldConfig browserConfig = new MyBrowserFieldConfig();
homeBrowserField = new BrowserField(browserConfig);
tabArea.add(homeBrowserField);
browserConfig.setProperty(BrowserFieldConfig.CONTROLLER, new MyBrowserFieldController(homeBrowserField));

MyBrowserFieldConfig browserConfig = new MyBrowserFieldConfig();  homeBrowserField = new BrowserField(browserConfig); tabArea.add(homeBrowserField);  browserConfig.setProperty(BrowserFieldConfig.CONTROLLER, new MyBrowserFieldController(homeBrowserField));

 

 

public class MyBrowserFieldController extends ProtocolController 

 implements BrowserFieldController {

 

 BrowserField browserField;

 

 public MyBrowserFieldController(BrowserField browserField) {

 super(browserField);

 this.browserField = browserField;

 }

 

 public void handleNavigationRequest(BrowserFieldRequest request)

 throws Exception {

 

 

 if (patternmatched) {

BrowserSession b = Browser.getDefaultSession();

 b.displayPage(request.getURL());

 } else {

                  //Tried these 2 but didn't work

                 // setNavigationRequestHandler(request.getProtocol(),(BrowserFieldNavigationRequestHandler) request); //browserField.requestContent(request.getURL());

 }

 return;

 }

 

 public InputConnection handleResourceRequest(BrowserFieldRequest request)

 throws Exception {

 return (InputConnection)Connector.open(request.getURL());

 }

 

}

 

                  .

 

------

Not sure if I'm doing the right thing here. Can anyone please suggest something.

 

thank you,

Rojina

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Using BrowserFieldController & ProtocolController to intercept clicks

Can't help with your question, but I suspect Dev49 from DevCon 2010 can.  So download and review it. 

 

Have a look here:

 

https://www.blackberry.com/bdsc/?lang=na#devcon

 

You might need to sign on to Developer Zone first. 

New Contributor
Posts: 2
Registered: ‎04-15-2010
My Device: 8100 - 9000
My Carrier: Orange Fr

Re: Using BrowserFieldController & ProtocolController to intercept clicks

else {
super.handleNavigationRequest(request);

}
New Contributor
Posts: 2
Registered: ‎04-15-2010
My Device: 8100 - 9000
My Carrier: Orange Fr

Re: Using BrowserFieldController & ProtocolController to intercept clicks

override public InputConnection handleResourceRequest is not necessary