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: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

BrowserField redirection handling

How  can i handle redirection of URL in blackberry bowserfield?

		public void documentCreated(BrowserField browserField,
						ScriptEngine scriptEngine, Document document)
						throws Exception {
					
					if ((browserField != null) && (document != null)) {
						String url = document.getBaseURI();
						for (int i = 0; i < items.size(); i++) {
							Item item = (Item) items.elementAt(i);
							System.out.println("*******URL*******" + url);

							String urlpattern = item.getAttribute("urlpattern");
							if (url.indexOf(urlpattern) != -1) {

								AppComponent.getInstance().loadPage(
										item.getAttribute("link"));
								return;
							}
						}
					}
					super.documentCreated(browserField, scriptEngine, document);
				}

 I am using this code,but when i come back to my earlier pgae,it again reloads the url,which i dont want

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

Re: BrowserField redirection handling

Can you explain this question another way, I am not sure of the sequence of events that is occurring and the processing that you wish to happen.

Highlighted
Developer
Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: BrowserField redirection handling

Ok let me explain in detail.I am calling a url in the browserfield.The webpage has three sections Music,Videos and Wallpapers.When i click on say Music,its going to an empty page in the browser,and internally it redirects to another page whose URL i can capturing.Than i see that if the URL has music in it,i am calling my native music screen,same for videos and wallpaper.So once i go to the native music screen and click back,it comes back to the earlier empty page.I want to avoid this.I want that if i click back,it should come to the first webpage when the app was loaded for the first time.

 

screenA                                    ScreenB

webpage-------->                   empty webpage and redirecting to my native screen

 

Native screen click back----->instead of coming to empty screen---->it should come to the first webpage

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

Re: BrowserField redirection handling

In your code, you call this:

AppComponent.getInstance().loadPage(item.getAttribute("link"));

to go to your native screen.

 

After that you could do a

browserField.back();

to return the browser field to the previous screen.

Developer
Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: BrowserField redirection handling

yes exactly i am using 

AppComponent.getInstance().loadPage(item.getAttribute("link"));

 to go to my native screen.So after browserfield.back() do i need to return?

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

Re: BrowserField redirection handling

Sorry my previous post did not make it clear.  After you do :

 

AppComponent.getInstance().loadPage(item.getAttribute("link"));

 

to go to your native scree, you should do  a

 

browserField.back();

 

to return to the previous browserfield screen.