06-30-2010 01:20 AM
Hi all,
I am working on 5.0.
I am using BrowserField in my app to load an URL. while refrehsing the content it is throwing illegalstateexception.
anybody have any ideas regarding this??
the following is the code
btnRefresh.setChangeListener(new FieldChangeListener()
{
public void fieldChanged(Field field, int context)
{
try
{
// throwingException browser.refresh();
}catch(Exception e)
{
Tools.print("XCO:MyBrowserFieldScreen:Refresh: Error" + e.toString());
}
}
});
06-30-2010 02:07 AM
While debugging i found that an error is throwing at the line
BrowserField.deleteAll();
actually am not adding any fields to browser. But somehow it is throwing me error, while calling
browser.refresh();
browser.forward();
browser.back();
methods..
06-30-2010 04:24 AM
maybe an eventlock problem? what is the detail message of the exception?
try to run it in an invokelater.
06-30-2010 04:54 AM
Thanks simon,
am calling this browserfield screen in eventlock.
the following is the error msg:
XCO:MyBrowserFieldScreen:Refresh: Errorjava.lang.IllegalStateException: tried to remove FieldWithFocus
actually am placing the browser.refresh() in try/catch, still a simulator crash is happening and when i click on "continue" the control is back to app.
i will try with invokelater and let you know the latest result.
06-30-2010 05:07 AM
i know the "delete field with focus" error. try to set the focus on one of your own fields before executing deleteAll
06-30-2010 05:11 AM
actually the focus is on a custom button.
i have back, next, refresh as custom buttons and am calling the browser.back(), browser.refresh() in their fieldChangeListeners.
am not at all trying to delete any field while refreshing/back/next. so can you tell a litle more over
"try to set the focus on one of your own fields before executing deleteAll"
06-30-2010 05:12 AM - edited 06-30-2010 05:25 AM
Hi simon,
i tried with what you said. i removed the eventlock while pushing the screen and now pushing the screen in the invokelater... still the same problem.
the following is the code
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
MyBrowserFieldScreen screen = new MyBrowserFieldScreen(clikthruURL);
TransitionContext transitionContextIn = new TransitionContext(TransitionContext.TRANSITION_SLI DE);
transitionContextIn.setIntAttribute(TransitionCont ext.ATTR_DURATION, 300);
transitionContextIn.setIntAttribute(TransitionCont ext.ATTR_DIRECTION, TransitionContext.DIRECTION_UP);
TransitionContext transitionContextOut = new TransitionContext(TransitionContext.TRANSITION_SLI DE);
transitionContextOut.setIntAttribute(TransitionCon text.ATTR_DURATION, 300);
transitionContextOut.setIntAttribute(TransitionCon text.ATTR_DIRECTION, TransitionContext.DIRECTION_DOWN);
transitionContextOut.setIntAttribute(TransitionCon text.ATTR_KIND, TransitionContext.KIND_OUT);
UiEngineInstance engine = Ui.getUiEngineInstance();
engine.setTransition(null, screen, UiEngineInstance.TRIGGER_PUSH, transitionContextIn);
engine.setTransition(screen, null, UiEngineInstance.TRIGGER_POP, transitionContextOut);
UiApplication.getUiApplication().pushScreen(screen );
}
});
06-30-2010 05:21 AM
I have had similar problems with BrowserField, which I "fixed" by setting the focus back on the BrowserField before doing an action on it. Try that.
06-30-2010 05:55 AM
working peter!!!
thanks!!
thanks simon.
once again thankU peter!!
but when i did a monkey testing on refresh button, it crashed throwing the same error!!
JVM error: 104
uncaught: IllegalStateException:
can you tell me why it is happening??
06-30-2010 08:27 AM
Refresh button?
Just to confirm, my code looks like
browserField.setFocus(); // Overcome random BrowserField bug
browserField.refresh();