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
Contributor
Posts: 26
Registered: ‎05-26-2011
My Device: TORCH 9800
My Carrier: T Mobile

Dealing with several BrowserFields : Blank?

Hello guys! After using and abusing of all the useful informations of this forum it looks like it's my time to post a problem:

 

Im working on OS 6.0

 

in the app Im working on, I need to display 3 different BrowserFields alternately. I first try to deal with 3 different screens (by poping one then pushing an other one) and now Im only using one screen but using 3 different Managers (each one containing a browserfield) but the problem is the same: I can display each BrowserField only once, when I try to go back to a previously seen one, I always get a Blank screen. I've tried to use .refresh() method everytime I want to display the browserfield but thats not changing anything. 

 

Anybody managed to solve this problem? Dont hesitate to ask me more details

 

Remilito

 

PS: I've implemanted a Web Cache for the BrowserField following this: http://supportforums.blackberry.com/t5/tkb/articleprintpage/tkb-id/java_dev@tkb/article-id/574, it works great, I recommend it if you want to speed up your BrowserField for example ;-)

Contributor
Posts: 26
Registered: ‎05-26-2011
My Device: TORCH 9800
My Carrier: T Mobile

Re: Dealing with several BrowserFields : Blank?

still not working... here is an extract from my code:

              
// this is the listener of a button for one of the three manager
// there are two others button which work the same way

   BrowserField bf;
	    	 BrowserFieldContainer cf; //cf contains bf
	    	      // cf is in the manager manHOME
	    	  try {
	    		  THEAPP.screen.delete(THEAPP.screen.getField(0));
		// screen is the MainScreen which contains manHOME and the 2 others manager		THEAPP.screen.insert(THEAPP.screen.getManHOME(),0);
				  
				  	cf = (BrowserFieldContainer) ((VerticalFieldManager)THEAPP.screen.getField(0)).getField(0);

					 bf =  (BrowserField) cf.getField(0);
					 bf.invalidate();
					 
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				Dialog.alert(e.getClass().getName());
				Dialog.alert(e.getMessage());
			}

 with it, I get no exception, the switching between the 3 managers works perfectly. Its just that the browserfield of each manager appears with a Blankscreen.    For info, during the creation of the three managers, I use requestContent(url) for the three BrowserField and it works. So I dont know what is going on, why I just cant retrieve the same BrowserField with the same content and not that blank screen... any ideas?

 

Highlighted
Contributor
Posts: 26
Registered: ‎05-26-2011
My Device: TORCH 9800
My Carrier: T Mobile

Re: Dealing with several BrowserFields : Blank?

oS: 6.0

Device: Torch 9800
IDE: plugin for eclipse 1.3.0 

 

So I still dont understand the problem with BrowserField, its seems that it looses its url adress when an other Browserfield is displayed but even if I memorize the url displayed and ask again for requestContent(url_memorized) when I want to display this browserfield again, it doesnt work, like the browserfield is blocked or something. 

Example:

Browserfield1 with url_1 is displayed.

I put url_1 value in a variable and then display Browserfield2 which display url_2 (I switch by switching the manager of the mainscreen)

then I want to display Browserfield1, I use requestContent(url_1)  and then display Browserfield1

I get Browserfield1 but with a blankscreen and I cant do anything else, its blocked.

 

If anyone has an idea of what is going on with Browserfield, let me know.

 

until I find a real solution, I create a new BrowserField everytime I have to switch and requestContent(url_saved). It works but of course its very slow and cost a lot in data transfert. :

 

/*Im currently displaying an "OFFERS" browserfield and I want to now display a "HOME" browserfield, being able to go back to "OFFERS" browserfield in the same state.*/

// I memorize the current url 
screen.setUrlOFFERS(screen.getBfOFFERS().getDocumentUrl());

// I delete the manager, named current, displaying the browserfield
screen.delete(current);

// I delete the current browserfield "OFFERS"	
screen.getContainerOFFERS().delete(screen.getBfOFFERS());

// I replace it with subsitute = new Browserfield()
screen.setBfOFFERS(substitute);
	    				 
// request the new browserfield to displayed the url previously memorized
screen.getBfOFFERS().requestContent(screen.getUrlOFFERS());
	    	    		
// adding the new browserfield to his container which is contained by
// the manager "current"
screen.getContainerOFFERS().insert(screen.getBfOFFERS(), 0);
	    	    		
// invalidate everythings, maybe useless
screen.getBfOFFERS().invalidate();
screen.getContainerOFFERS().invalidate();
screen.getManOFFERS().invalidate(); // manOFFERS = current

// insert the new manager which contains the browserfield "HOME"	    	    		
screen.insert(screen.getManHOME(),0);

/* so with this code I display a browserfield while building a copy of the previous one for next time I want to display it */

 so what I want to do would be:

/*Im currently displaying an "OFFERS" browserfield and I want to now display a "HOME" browserfield, being able to go back to "OFFERS" browserfield in the same state.*/

// I memorize the current url 
screen.setUrlOFFERS(screen.getBfOFFERS().getDocumentUrl());

// I delete the manager, named current, displaying the browserfield
screen.delete(current);

// insert the new manager which contains the browserfield "HOME"	    	    		
screen.insert(screen.getManHOME(),0);

// request the PREVIOUS browserfield to displayed the url previously memorized
// I have to do that because its seems that the BField looses his content_url
// when I display an other one

screen.getBfOFFERS().requestContent(screen.getUrlOFFERS());
	    	    	
// invalidate everythings, maybe useless
screen.getBfOFFERS().invalidate();
screen.getContainerOFFERS().invalidate();
screen.getManOFFERS().invalidate(); 

/* so with this code Im supposed to be able to re display OFFERS browserfield in the same state than before displaying HOME browserfield, but i do it (calling with a button for example) I get a blank blocked screen  */

 

anyone has already faced this problem?

Contributor
Posts: 11
Registered: ‎06-07-2011
My Device: Bold 9780
My Carrier: Rogers

Re: Dealing with several BrowserFields : Blank?

[ Edited ]

Hello I just ran into this problem today and found that to get past it you must re-initialize the BrowserField everytime.

 

For example, I used deleteAll() on my Manager and when I went to add the already initialized BrowserField it showed up blank.

 

BrowserField bField = new BrowserField(config);
bfield.displayContent(...);
add(bfield); //Will show the content
deleteAll();
add(bfield); //Will be blank

 

 

If you instead re-initialize the variable when you need to refresh you can by-pass this problem. 

 

 

BrowserField bField = new BrowserField(config);
bfield.displayContent(...);
add(bfield); //Will show the content
deleteAll();
bField = new BField(config);
bfield.displayContent(...);
add(bfield); //Will show the content

 

This is obviously a problem that needs to be fixed though.

 

Note: I am using JDE 5.0.0 on a Bold 9780.

Contributor
Posts: 26
Registered: ‎05-26-2011
My Device: TORCH 9800
My Carrier: T Mobile

Re: Dealing with several BrowserFields : Blank?

[ Edited ]

Thank you for your answer! Creating a new Browserfield every time is the solution I am currently using because nothing else seems possible right now but... the waist of time and memory is very annoying. I hope too that they will fix this problem, because there is no reason why we couldn't display, hide and redisplay the same BrowserField. If anyone from RIM read this...

Contributor
Posts: 26
Registered: ‎05-26-2011
My Device: TORCH 9800
My Carrier: T Mobile

Re: Dealing with several BrowserFields : Blank?

For Information: I've just tested on OS 7.0 (with 9900 simulator) and the problem is still present.Here is  the simple code I've used:

package mypackage;

import net.rim.device.api.browser.field2.BrowserField;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

/**
 * A class extending the MainScreen class, which provides default standard
 * behavior for BlackBerry GUI applications.
 */
public final class MyScreen extends MainScreen
{
    /**
     * Creates a new MyScreen object
     */
	 final int BF1 = 0;
	 final int BF2 = 1;
	 int current;
	 BrowserField bf1;
	 BrowserField bf2;
	 ButtonField button;
	 FieldChangeListener listener;
	 VerticalFieldManager manMAIN;
	 VerticalFieldManager man1;
	 VerticalFieldManager man2;
    public MyScreen()
    {        
        // Set the displayed title of the screen       
        setTitle("Essai");
        current = BF1;
        bf1 = new BrowserField();
    	bf2  = new BrowserField();
    	manMAIN = new VerticalFieldManager();
    	man1 = new VerticalFieldManager();
    	man2 = new VerticalFieldManager();
    	
    	bf1.requestContent("http://www.google.com");
    	bf2.requestContent("http://www.yahoo.com");
    	
    	 listener = new FieldChangeListener(){

 			public void fieldChanged(Field field, int context) {
 				// TODO Auto-generated method stub
 				Dialog.alert("Current : "+current);
 				if ( current == BF1 ){
 					manMAIN.delete(man1);
 					manMAIN.insert(man2,1);
 					current = BF2;
 					manMAIN.invalidate();
 					
 				}
 				else if ( current == BF2 ){
 					manMAIN.delete(man2);
 					manMAIN.insert(man1,1);
 					current = BF1;
 					manMAIN.invalidate();
 				}
 				else
 					Dialog.alert("Problem");
 				
 				Dialog.alert("Current : "+current);
 			}
 			
 		};
    	
    	button = new ButtonField("SWITCH");
		button.setChangeListener(listener);
		
		
		
		man1.insert(bf1, 0);
		man2.insert(bf2, 0);
		
		manMAIN.insert(button,0);
		manMAIN.insert(man1,1);
		
		
		this.add(manMAIN);
		
    	
		
		
    }
    
}

 

New Developer
Posts: 16
Registered: ‎04-24-2011
My Device: Playbook and curve 6530
My Carrier: MTS

Re: Dealing with several BrowserFields : Blank?

If you breakpoint documentUnloading in your browserfieldlistener you will see that anytime a page is loaded in one browserfield the otherbrowserfield unloads its page. This is not how it should work but it is what it is. I was hoping os7 fixed this but I guess not.