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: 44
Registered: ‎01-12-2011
My Device: Not Specified

BrowserField's displayContent not working on device.

Hi

 

I am trying to display an HTML string in the BrowserField. It is working fine on OS 5.0 and 6.0 Simulators. But it is not working on device. What could be the reason. Please suggest. This is the code that I am using

 

 

BrowserFieldConfig config = new BrowserFieldConfig();
		HttpHeaders headers = new HttpHeaders();
		headers.addProperty(HttpHeaders.HEADER_CONTENT_TYPE, HttpHeaders.CONTENT_TYPE_TEXT_HTML);
		headers.addProperty(HttpHeaders.HEADER_ACCEPT_CHARSET, "UTF-8");
		config.setProperty(BrowserFieldConfig.HTTP_HEADERS, headers);
		BrowserField contentField = new BrowserField(config);
		add(contentField);
		contentField.displayContent(content,"http://localhost");

 

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: BrowserField's displayContent not working on device.

What doesn't work?  Can you elaborate on the issue you are seeing.  Is any error or exception thrown?  Note that you shouldn't use localhost in your URL.  Is that the URL you are actually using or replaced as a sample?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Contributor
Posts: 44
Registered: ‎01-12-2011
My Device: Not Specified

Re: BrowserField's displayContent not working on device.

Thanks for your reply. 

 

I am passing the html script in the string form to displayContent. e.g. content may be "<p>blackberry<\p>". When I run this on simulator it renders the html script and shows "blackberry" on screen but when I run this on device. It does not show anything, not even the white background of browser field. As I am not taking data from any web page or local html file, I have tried both http://localhost" and leaving the url blank. Both ways it works on simulator but not on device.

 

Please suggest.

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: BrowserField's displayContent not working on device.

Which BlackBerry Smartphone model and BlackBerry handheld software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.

 

Can you provide a code snippet that shows exactly what you are doing?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Contributor
Posts: 44
Registered: ‎01-12-2011
My Device: Not Specified

Re: BrowserField's displayContent not working on device.

I am using Blackberry Bold 9780 Platform Version 6.5.0.13

 

Here is the actual code that I am using

import net.rim.device.api.browser.field2.BrowserField;
import net.rim.device.api.browser.field2.BrowserFieldConfig;
import net.rim.device.api.io.http.HttpHeaders;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

public class MyScreen extends MainScreen {

	private VerticalFieldManager screenVFM= new VerticalFieldManager();

	public MyScreen(String htmlText) {
		super(Manager.NO_VERTICAL_SCROLL);

		BrowserFieldConfig config = new BrowserFieldConfig();
		HttpHeaders headers = new HttpHeaders();
		headers.addProperty(HttpHeaders.HEADER_CONTENT_TYPE, HttpHeaders.CONTENT_TYPE_TEXT_HTML);
		headers.addProperty(HttpHeaders.HEADER_ACCEPT_CHARSET, "UTF-8");
		config.setProperty(BrowserFieldConfig.HTTP_HEADERS, headers);
		BrowserField contentField = new BrowserField(config);

		screenVFM.add(contentField);
		add(screenVFM);
		contentField.displayContent(htmlText,"");
	}
}

 

Contributor
Posts: 44
Registered: ‎01-12-2011
My Device: Not Specified

Re: BrowserField's displayContent not working on device.

I am simplye making an object of this screen on hitting a field and pushing it.

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: BrowserField's displayContent not working on device.

What content is in htmlText?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Contributor
Posts: 44
Registered: ‎01-12-2011
My Device: Not Specified

Re: BrowserField's displayContent not working on device.

It can be anything. e.g text in a paragraph tag like.. "<p>blackberry<\p>".

 

It works on simulator it means the text is ok. I have also printed it before passing it to displayContent. It is coming right.

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: BrowserField's displayContent not working on device.

Is that all you have or are you using a complete string of HTML (i.e. HTML opening, closing tags, etc...)?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Contributor
Posts: 44
Registered: ‎01-12-2011
My Device: Not Specified

Re: BrowserField's displayContent not working on device.

It may be anything. with opening and closing html tags or without opening and closing html tags. It may just be a text within paragraph tags as I mentioned above.