06-16-2011 08:27 AM
Hello.
After a software update from v.6.0.0.246 to v.6.0.0.546 my browser control shows the content only once.
After I poped the screen with die browserfield from the display stack and pushed it later to the stack, no content is shown.
And yes it happened also if u set the content in the onDisplay() event with requestContent(). Also fails refresh() or other funktions of the field to show/paint something. The browserfield stays empty!
In software version v.6.0.0.246 everything works fine. Whats wrong?
Here a little sample program with the problem:
public final class BrowserPopPushTest extends UiApplication
{
public static MyMainScreen myMainScreen = null;
public static MyBrowserScreen myBrowserScreen = null;
public static void main(String[] args)
{
BrowserPopPushTest app = new BrowserPopPushTest();
app.enterEventDispatcher();
}
public BrowserPopPushTest()
{
myMainScreen = new MyMainScreen();
myBrowserScreen = new MyBrowserScreen();
pushScreen(myMainScreen);
}
}with 2 screens:
1.
public final class MyMainScreen extends MainScreen implements FieldChangeListener
{
ButtonField mButton = null;
MyMainScreen()
{
mButton = new ButtonField("Goto Browser screen", ButtonField.CONSUME_CLICK);
mButton.setChangeListener(this);
add(mButton);
}
public void fieldChanged(Field field, int context)
{
if (field == mButton)
{
UiApplication.getUiApplication().pushScreen(TestBE A1.BrowserPopPushTest.myBrowserScreen);
UiApplication.getUiApplication().popScreen(TestBEA 1.BrowserPopPushTest.myMainScreen);
}
}
protected boolean onSavePrompt()
{
return true;
}
}2.
public final class MyBrowserScreen extends MainScreen
{
private BrowserField myBrowserField;
MyBrowserScreen()
{
myBrowserField = new BrowserField();
add(myBrowserField);
}
public void onDisplay()
{
myBrowserField.requestContent("local:///LocalText. html");
}
public boolean onClose()
{
UiApplication.getUiApplication().pushScreen(TestBE A1.BrowserPopPushTest.myMainScreen);
UiApplication.getUiApplication().popScreen(TestBEA 1.BrowserPopPushTest.myBrowserScreen);
return true;
}
}Very simple.
If u press the button on the first sreen (myMainScreen) the second screen(myBrowserScreen) will pushed on the stack and shows the content from a local file in the browserfield.
If u go back (BB button on the device) first screen will pushed, second poped.
AND if u now press the Button on the first sreen once again the second screen is shown with the empty browserfield. There is no chance to load any content to the field.
AND the BB back button also do not work now!
Whats happened in this firmeware version?
Any ideas?
Solved! Go to Solution.
06-20-2011 01:39 AM
Nobody else got the Problem with the Browserfield?
No ideas?
06-22-2011 10:46 AM
Hello Falk,
This appears to related to known issues with BrowserField as of 50 whenever the UiEngine is detached from the containing screen:
- https://www.blackberry.com/jira/browse/JAVAAPI-146
- https://www.blackberry.com/jira/browse/JAVAAPI-146
Based on the noted discussions, I would expect that your approach of calling BrowserField.requestContent(...) on display would properly reload this content; however I am seeing the same issues you are and have reproduced using the latest 7.0 SDK.
One recommendation I would make is to drop onDisplay() and make use of onUiEngineAttached(...) instead, as onDisplay() has been deprecated.
The workaround I have found includes:
1) Doing nothing in the constructor for MyBrowserScreen.
2) If the UI engine is attached, we set myBrowserField to a new BrowserField, attach it to the screen, and request the content.
3) If the UI engine is detached, we delete all the fields on the screen and set our BrowserField Object (myBrowserField) to null.
* You could also omit myBrowserField completely.
The above implementation prevents the issues with:
1) Being unable to re-request content; and
2) The escape key not working.
I've also tried catching any Exceptions to see if something was erroring out mid-way, but the code appears to execute successfully (aside from the requestContent() method simply not having any effect.)
Would the above approach meet your needs?
Erik Oros
BlackBerry Development Advisor
06-23-2011 03:38 AM
Thanks Erik for the response.
I am able to redesign the application next week. I will figure out if your solution to prevent the problems with the browserfield can used in my app.
Till then
Falk
07-04-2011 10:47 AM
OK Erik,
I have implemented the way you suggest.
My application now works fine again.
Thank you
Falk
09-24-2012 08:52 AM
Hello,
I'm having the same issue here: http://supportforums.blackberry.com/t5/Java-Develo
So, you're saying i need to create a new browserfield whenever i need to redisplay the contents of the SAME webpage? I don't think this is acceptable in terms of data traffic and load time.
In order to improve user experience, i;m trying to cache the webpage locally and display it inside a new BrowserField using BrowserField.displayContent(byte[] ...), avoiding unnecessary data traffic and reducing the loadtime. But there are issues with images which are fetched in separate http requests... which i need to parse from the initial webpage. Not to mention the JavaScript which may have already modified the webpage in the previous browserfield.
Is there any other way to solve this inconvenience?