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
Developer
arunbiet
Posts: 384
Registered: ‎06-22-2010
My Device: na

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
peter_strange
Posts: 19,609
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.

Developer
arunbiet
Posts: 384
Registered: ‎06-22-2010
My Device: na

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
peter_strange
Posts: 19,609
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
arunbiet
Posts: 384
Registered: ‎06-22-2010
My Device: na

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
peter_strange
Posts: 19,609
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.