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
Super Contributor
Posts: 398
Registered: ‎01-12-2011
My Device: Q10
My Carrier: Fido

BrowserField IllegalStateException

Hi.

 

I have a screen in my app with a custom button which opens a modal screen containing a BrowserField and a custom BACK button.

 

The button that opens the screen with the BrowserField does the following:

 

myCheckInScreen.myBrowserField.requestContent(myWebSiteURL);

UiApplication.getUiApplication().pushModalScreen(myCheckInScreen);

 

The back button basically closes the screen:

 

if(field == backTab)
  {
        UiApplication.getUiApplication().getActiveScreen().close();
  }

 

When I click to open the screen with the BrowserField, it opens and displays the website as expected. When I click the back button on that screen it closes it and goes back to the previous screen as expected.

 

But if I click to open the BrowserScreen again it gives me an IllegalStateException. What does this mean??

 

When I hit the back button from the BrowserScreen do I have to do any additional work, such as delete anything??

 

Thanks.

 

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: BrowserField IllegalStateException

[ Edited ]

Sounds like the screen did not get closed. If you attempt to push the screen again (and it is already on the display stack), you'll get this error.

 

I don't like the "getUiApplication()" here - depending on the context, this may not retrieve *your* application. Retain a refefence to the screen and close it using this reference (or pop the screen).

 

 

 

Super Contributor
Posts: 398
Registered: ‎01-12-2011
My Device: Q10
My Carrier: Fido

Re: BrowserField IllegalStateException

[ Edited ]

Thanks for the help.

 

It seems to work ok if I do the following:

 

if(field == backTab)
  {
        UiApplication.getUiApplication().getActiveScreen()​.close();

        myBrowserField.deleteAll();
  }

 

I mean, obviously I should not use getUiApplication().getActiveScreen as you mentioned, but now it's not throwing the IllegalStateException.

 

Is this a good approach???

Super Contributor
Posts: 398
Registered: ‎01-12-2011
My Device: Q10
My Carrier: Fido

Re: BrowserField IllegalStateException

No it's not working.

 

Sometimes when I click a link on the web page it gives me that same error. It's driving me nuts.

 

How do I use a BrowserField correctly?? Also it takes so long to load a page, and that's on the simulator, I can only imagine how long it would take on a device then.

 

Also I can't seem to scroll horizontally, only vertically. So in many cases I can't see the whole page, unless it's a mobile site.

 

Thanks again for your time.

Super Contributor
Posts: 398
Registered: ‎01-12-2011
My Device: Q10
My Carrier: Fido

Re: BrowserField IllegalStateException

I'm now convinced that it has something to do with the focus.

 

I just removed my back button and everything works fine. I can click links and everything seems ok. How can I get the BrowserField and my back button to co-exist??

 

Thanks.