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
Highlighted
New Developer
Posts: 17
Registered: ‎12-02-2009
My Device: Not Specified
Accepted Solution

BrowserField OS 5.0 STORM2

Hi,

 

I am using net.rim.device.api.browser.field2.BrowserField to render HTML content in my app. I am able to render the content using 

BrowserField browserField = new BrowserField();

browserField.displayContent(htmlcontent, http://localhost);

 

However, I am unable to replace the rendered content with new one. I tried deleting the field as well, but no luck.

 

Every other attempt of browserField.displayContent(newHtmlcontent, http://localhost); results in throwing NullPointerException @ SingleUseWindow$SingleUseFieldWrapper(Manager).deleteRange(int, int) line: 1056 

Has someone faced the same issue as this? Any solutions?

 

Thanks

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

Re: BrowserField OS 5.0 STORM2

The first step should be to change from localhost to your actual PC name or IP address.  The use of localhost is restricted on BlackBerry Smartphones.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
New Developer
Posts: 17
Registered: ‎12-02-2009
My Device: Not Specified

Re: BrowserField OS 5.0 STORM2

Thanks for the reply Mark.

 

Could you tell me the correct way to rerender HTML content?

New Developer
Posts: 17
Registered: ‎12-02-2009
My Device: Not Specified

Re: BrowserField OS 5.0 STORM2

Hi,

 

I am using the older implementation to render HTML content, recommended by RIM for versions below 5.0 Refer:http://docs.blackberry.com/en/developers/deliverables/11935/Display_content_in_BB_Browser_field_5655.... HTML content does not render at all on Storm2( 9550) OS 5.0.0.334. I found a workaround through support forums, but text wrapping is not happening with this implementation.

 

Has anyone faced this issue? any workaround?

 

-  Thanks bbdeveloper2009

Developer
Posts: 157
Registered: ‎02-18-2009
My Device: Not Specified

Re: BrowserField OS 5.0 STORM2

Are you sure that the parent element of the BrowserField is not wider than the screen? Could you post the relevant code that adds the BrowserField to the screen?

New Developer
Posts: 17
Registered: ‎12-02-2009
My Device: Not Specified

Re: BrowserField OS 5.0 STORM2

vertical_mngr = new VerticalFieldManager(Manager.VERTICAL_SCROLL|Manager.NO_HORIZONTAL_SCROLL){
 protected void sublayout( int maxWidth, int maxHeight )
 {
  super.sublayout(100, 200);
  setExtent(100, 200);
 }
}

---------------------------------------------------------------------------------------------------------------------

browserField = new CustomBrowserField(htmlText, vertical_mngr);

---------------------------------------------------------------------------------------------------------------------

CustomBrowserField is the class that creates a HTTPConnection thread to load 

ByteArrayInputStream of the htmltext using DataInputStream in this way:

new DataInputStream(new ByteArrayInputStream(htmlText.getBytes("UTF-8")));

---------------------------------------------------------------------------------------------------------------------

implementation for method used to render the HTML content

browserContent = renderingSession.getBrowserContent(connection, this, 49);
if (browserContent != null) {
 field = browserContent.getDisplayableContent();
 if (field != null) {
  synchronized (Application.getEventLock()) {
   try {
    vertical_mngr.add(field);
   } catch(Exception exc) {
    //System.out.println("processConnection :"+exc.getMessage());
   }
  }
 }
 browserContent.finishLoading();

 

int 49 is used to render html content on the Storm2(OS 5.0.0.334) device. Refered http://supportforums.blackberry.com/t5/Java-Development/Base-URI-must-be-non-null-NP-exception-throw...

---------------------------------------------------------------------------------------------------------------------

Developer
Posts: 157
Registered: ‎02-18-2009
My Device: Not Specified

Re: BrowserField OS 5.0 STORM2

I do not have a Storm 2 to test. Is it reproducable in the simulator?

New Developer
Posts: 17
Registered: ‎12-02-2009
My Device: Not Specified

Re: BrowserField OS 5.0 STORM2

yes, it is reproducable on simulator.

Developer
Posts: 157
Registered: ‎02-18-2009
My Device: Not Specified

Re: BrowserField OS 5.0 STORM2

Seems to work for me on a Storm 2 simulator (i.e. the HTML is wrapped when it doesn't fit the screen).

 

Can you post a screenshot to make sure I completely understand what your problem is?

 

Another thing you could try is not to use your own VerticalFieldManager. Can you add the HTML field directly to the screen? (or to a standard VerticalFieldManager not overriding sublayout)

New Developer
Posts: 17
Registered: ‎12-02-2009
My Device: Not Specified

Re: BrowserField OS 5.0 STORM2

Hi Martin,

 

I tried adding the field directly to MainScreen. It still does not wrap on screen. Also tried adding it to a vertical manager having no overridden sublayout() but no luck.

(Compiling against component pack 4.7.0)

 

Thanks,
bbdeveloper