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
Regular Contributor
Posts: 55
Registered: ‎09-01-2010
My Device: Not Specified
Accepted Solution

Uncaught IllegalStateException

I want to add previous and forward button to controll the 'BrowserField'  in my app. But often it is giving "JVM 104 error: uncaught IllegalStateException" for the statement 'browserFieldHistory.goBack()' and also for "browserFieldHistory.goForward()"

 

private final class ButtonListener implements FieldChangeListener {
        public void fieldChanged(Field field, int context) {

           ........

           if(field == BackButton)  // back
           {
               try {
                browserFieldHistory = getBrowserField().getHistory();
                if(browserFieldHistory.canGoBack())
                {
                    try {
                        browserFieldHistory.goBack();
                    } catch (IllegalStateException e){
                        Log.info("Error executing js:back(): ");
                    }
                }
               } catch(IllegalStateException e){                        
                    Log.info("Error executing js:back(): ");
               }
           }
           if(field == ForwardButton) // forward
           {
               try{
                    browserFieldHistory = getBrowserField().getHistory();
                    if(browserFieldHistory.canGoForward())
                    {
                        try {
                            browserFieldHistory.goForward();  
                        } catch(IllegalStateException e) {
                        }
                    }                                                 
               } catch(IllegalStateException e) {                        
                    Log.info("Error executing js:next(): ");
               }
           }
        }
    }

 

    Although both of the statement are in the "try-catch" with IllegalStateException handling, still it is throwing uncaught exception. Can anyone point out the error in my code?

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

Re: Uncaught IllegalStateException

As an experiment, set the focus on the BrowserField before you do this.

 

                    try {
                        browserFieldHistory.setFocus();

                        browserFieldHistory.goBack();
                   

Highlighted
New Contributor
Posts: 9
Registered: ‎01-18-2011
My Device: Not Specified

Re: Uncaught IllegalStateException

Thanks Peter. It works perfectly fine.

New Developer
Posts: 2
Registered: ‎01-21-2013
My Device: Developer
My Carrier: Developer

Re: Uncaught IllegalStateException

[ Edited ]

Thanks for the solution.I think you meant to set focus for "BrowserField" object rather "BrowserFieldHistory". 

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

Re: Uncaught IllegalStateException

Opps, you are correct!