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
Highlighted
New Contributor
Posts: 2
Registered: ‎03-01-2011
My Device: Not Specified
Accepted Solution

Issue with focusable fields with higher priority than browserfield

This is for JRE6.

 

Some websites perform a content redirect, or other ajax request on load of the document.  When the screen contains a browserfield and contains a focusable field with a higher priority, an Illegal State Exception is thrown by the browser becuase it is not in focus when the content refreshes the field.  (Similar to setting BrowserField.setFocus() before calling BrowserField.refresh()).

 

Example: http://supportforums.blackberry.com/t5/Java-Development/BrowserField-Sample-Code-Create-your-first-B...

 

Using the Example BrowserField2 code, simply adding a ButtonField to the Title will throw the exception when navigating to twitter.com.  Other sites work fine, but when the content/javascript acts in a certain way like on Twitter, it seems to have some issues.

 

 

package mypackage;

import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.browser.field2.*;
import net.rim.device.api.ui.*;

class MyBrowserField2Sample extends UiApplication 
{    
	private MainScreen _screen;
	private BrowserField _bf2;
	private ButtonField btnField;
	
	MyBrowserField2Sample()  
	{	
		
		btnField = new ButtonField();
		btnField.setLabel("A BUTTON");
		
		
		
		_bf2 = new BrowserField();

		_screen = new MainScreen();
		_screen.setTitle(btnField);
	    _screen.add(_bf2);
		pushScreen(_screen);
		
		_bf2.requestContent("http://www.twitter.com");
	}

	public static void main(String[] args) 
	{
		MyBrowserField2Sample app = new MyBrowserField2Sample();        
		app.enterEventDispatcher();        
	}
} 

 The above code throws an illegal state exception at startup.  If you remove the setTitle, (or any focusable field) that has a higher priority than the browserfield, then it works ok.

 

How can I force focus on the browserfield when it needs it?

 

I've searched, found similar issues and all say 'force focus on the browserfield', but even if you force focus, the same illegal state occurs due to the contents refresh.

 

Thanks in advance,

Nate

 

 

New Contributor
Posts: 2
Registered: ‎03-01-2011
My Device: Not Specified

Re: Issue with focusable fields with higher priority than browserfield

After reviewing the issue further, the issue is possibly related to the focussable field, but it does not have to be on top.  Basically, any focussable field on the same screen as the browserfield will throw the exception.

 

While going to twitter.com within the blackberry browser works just fine (forwards you to the mobile site), this behavior causes issues with the browserfield.  

 

The workaround, is just force the link to open the mobile site directly.

Developer
Posts: 178
Registered: ‎07-29-2008
My Device: Not Specified

Re: Issue with focusable fields with higher priority than browserfield

The issue I belive was best answered by Marc here : http://supportforums.blackberry.com/t5/Java-Development/BrowserField2-API-scrolling-issue-on-OS-5-0/... 


This is a limitation of the BrowserField.  It is designed to take up the entire screen and doesn't fully support scrolling to other fields on the same screen.

So, taking this to the logical conclusion, it seems likely that the BrowserField being designed to work for the WebWorks Platform and not in a mix of native and html UI.  Setting focus on the field before calling requestContent might help.