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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

BrowserField: Do actions according to URL

I have a browserfield on screen. While navigating in browserfield i want to track urls and for a perticular url i have to push another screen. How should i do this? 

Developer
Posts: 434
Registered: ‎07-23-2012
My Device: Blackberry 10
My Carrier: Orange

Re: BrowserField: Do actions according to URL

Check with the following link

 

http://stackoverflow.com/questions/418105/embedded-html-control-for-blackberry

 

Some pointer keyword to search in Google


BrowserFieldController

RenderingApplication

extendScriptEngine

executeScript

 

 

 

Thanks
-------------------------------------------------------------------------------------
Press the Accept as solution Button when u got the Solution
Press Kudo to say thank to developer.
-------------------------------------------------------------------------------------.
Developer
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

Re: BrowserField: Do actions according to URL

It didnt help.
Contributor
Posts: 11
Registered: ‎03-23-2011
My Device: BlackBerry Bold
My Carrier: Verizon

Re: BrowserField: Do actions according to URL

[ Edited ]
//Attach a controller to the browser field		mBrowserField.getConfig().setProperty(BrowserFieldConfig.CONTROLLER, new BrowserController());


//Define actions to be done on URL calls
final class BrowserController extends ProtocolController{

private String URL_TO_TRAP = "http://us.blackberry.com/devices.html";		

     //Called when navigating to a new URL	
   public void handleNavigationRequest(BrowserFieldRequest request) throws Exception{
			
			if(request.getURL().equals(URL_TO_TRAP) ){
                               //custom action here
                         }

			super.handleNavigationRequest(request);		
     }
		
    //Called when the browser field is loading a resource(image, script etc)
    public InputConnection handleResourceRequest(BrowserFieldRequest request) throws Exception{
		
                        if(request.getURL().equals(URL_TO_TRAP) ){
                               //custom action here
                         }
			return super.handleResourceRequest(request);
     }		
}

 

You need to attach a controller to the browserfield and check every URL that is called. 

 

It is advisable to use "indexOf()" String comparison instead of equals to avoid clash with parameters within URL. 

e.g., you want to trap call to "http://us.blackberry.com/devices.html" but the actual call could be "http://us.blackberry.com/devices.html?lid=us:bb:devices&lpos=us:bb:devices"

 

Tell me this solved your problem! Smiley Happy

 

Highlighted
Developer
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

Re: BrowserField: Do actions according to URL

[ Edited ]

thanx. I tried this with BrowserFieldListener. I got my solution.

Contributor
Posts: 11
Registered: ‎03-23-2011
My Device: BlackBerry Bold
My Carrier: Verizon

Re: BrowserField: Do actions according to URL

BrowserFieldListener events are called AFTER/DURING the Page is loaded. It might cause errors if you delete the screen that contains the BrowserField on loading a URL. Using a controller is a better approach if this is what you are doing since those methods are called before a URL is requested.
Developer
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

Re: BrowserField: Do actions according to URL

i used it in documentCreated() method.
Developer
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
My Carrier: Vodafone

Re: BrowserField: Do actions according to URL

Suppose i am on page sample.aspx in browserfield.When i am on this page and i press back button i want to display some other screen. How should i do it?