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
New Contributor
Posts: 5
Registered: ‎03-26-2010
My Device: 9550
My Carrier: Rogers

Re: BrowserField rendering problems

Could someboday post example code to show how to set encoding of BrowserField like Blackberry browser? Thanks!

Regular Contributor
Posts: 64
Registered: ‎04-27-2010
My Device: Bold 9000
My Carrier: Vodafone

Re: BrowserField rendering problems

Netwang

 

If you're on v5.0 I suggest you use the new browser field provided. You can find sample code here net.rim.device.api.browser.field2.BrowserField

 

However, if you're on 4.6 or above, there's a hidden option in the rendering options that you set for the browserfield in your rendering session object. In 4.6 the browserfield implementation does not use the same base code as the BlackBerry browser but rather an older version. Using this hidden option you can actually force it to use the new base code that is used by the BlackBerry browser.

 

You can set it as follows

 

_renderingSession.getRenderingOptions().setProperty(RenderingOptions.CORE_OPTIONS_GUID, 17000, true);

 

I haven't tried this on versions earlier than 4.6. However, this worked for me on 4.6 but it is not supported so you'll have to use it at your own risk.

 

Also, you might want to look at some of the other options in the RenderingOptions class.

 

 

Finally, if all else fails you can create your own implementation of HttpConnection. What you would do is before passing the HttpConnection (the actual connection you use to connect to the server) to the browserfield so it would display the response content, you grab whatever is in this connection's input stream and pass it to your own implementation of HttpConnection. You do whatever pre-processing you need on the response and then pass your HttpConnectionImpl to the browserfield for display.

 

Hope that helps and let me know how things work out for you

Developer
Developer
Posts: 137
Registered: ‎06-01-2009
My Device: Not Specified

Re: BrowserField rendering problems

Thank you for the input. I would like to add few more comments:

 

  • < 4.6, both Java and Browser should display the same
  • >= 4.6, Browser uses new rendering engine (called ‘Mango’) while embedded Java browser field uses old rendering engine – content will appear different
  • 5.0, BrowserField2 (Java) and BlackBerry Browser both use new rendering engine (‘mango’), while Java apps that make use of the older browser.field API still use the older rendering engine

 

As well, when writing a Java application that makes use of the embedded browser field, you must enable certain features like JavaScript, images, CSS.  These features are disabled by default, and are not tied to the browser configuration settings that you set on your device.

New Contributor
Posts: 5
Registered: ‎03-26-2010
My Device: 9550
My Carrier: Rogers

Re: BrowserField rendering problems

Thanks for reply. But I am asking for code example for change the accept-language for BrowserContent like what the menu item "Set Encoding" of Blackberry browser does. I wrote the follwing code. But still can not display Chinese on Simulator. How to get Chinese works on Simulator? Any suggestions?

 

        String charset = "ISO-8859-1";
        String acceptCharset = "ISO-8859-1,UTF-8;q=0.9,UTF-16;q=0.8,US-ASCII;q=0.7"; //auto
        bkBrowserEncodingInfo info = bkBrowserEncodingPersistStore.get();
        if (info != null && !info.getAutoMode()) {
            charset = info.getCharset();
            if (! charset.equalsIgnoreCase("ISO-8859-1"))
                acceptCharset = charset + ";q=1,ISO-8859-1;q=0.9";
        }
        requestHeaders.addProperty("Accept-Charset", acceptCharset);
        
        RenderingOptions renderingOptions = renderingSession.getRenderingOptions();
        renderingOptions.setProperty(RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.DEFAULT_CHARSET_VALUE, charset);

Regular Contributor
Posts: 64
Registered: ‎04-27-2010
My Device: Bold 9000
My Carrier: Vodafone

Re: BrowserField rendering problems

Ok to set the accepted character set just simply use the below example

 

HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setProperty(REFERER, referrer);
requestHeaders.setProperty("Content-Language","en-US");                    
requestHeaders.setProperty("Accept-Language","en-us,en;q=0.5");                    
requestHeaders.setProperty("Accept-Charset","ISO-8859-1,utf-8;q=0.7,*;q=0.7");

 

 

Also use the overwrite char set rendering option using

 

_renderingSession.getRenderingOptions().setProperty(RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.OVERWRITE_CHARSET_MODE, true);

 

 

This way the browserfield will use the character set in the incoming html.

 

Hope this helps! If it works please mark as solved and kudos Smiley Happy

Contributor
Posts: 13
Registered: ‎06-18-2009
My Device: Not Specified

Re: BrowserField rendering problems

Hi Guys,

 

Thanks for the secret magic number, this works fine on 4.6 and 4.7 verified, but i have a case where i want to use the same browserfield that i developed for 4.7 to be used in 5.0 also and i tried to do it with the provided magic number (17000) and as far as display is concerned it worked fine but when i submitted my form (HTTP POST) and tried to fetch the POST data in the URL_REQUESTED_EVENT i always get the NULL value.

 

Can anybody suggest me what i am doing wrong. the code base is same as used in 4.7 and in 4.7 i am getting the post data.

 

As my pages are submitting some information on the web but in 5.0,  browserfield is not able to submit the data.

 

And i dont want to use the new browserfield so as to support the backward compatablity.

 

waiting for the suggestions.

 

Thanks

dc.

Highlighted
New Member
Posts: 1
Registered: ‎07-28-2010
My Device: Blackberry 9700
My Carrier: AT&T

BrowserField video playback bug

I am having a slightly different problem with BrowserField. Clicking on a video link crashes the whole app - but if i load the page in the browser on the device, the video plays fine...

 

Is there a workaround to this problem? Can I use something other than BrowserField to load a web page in my app?

 

Thanks in advance for your help!

 

Srini