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
Developer
Posts: 37
Registered: ‎10-10-2008
My Device: Not Specified
Accepted Solution

feed browserfield raw html from a local file

I'm trying to implement a cache kind of mechanism on an embedded browser app.(using browserfield). It seems that the only way browser field gets data is through HttpConnection getResource( RequestedResource resource, BrowserContent referrer)

 

How do I feed browserfield data from a different input stream that might not be a HttpConnection.

 

I would like to hear your thoughts

Thanks.

 

Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: feed browserfield raw html from a local file

Certainly for 4.0.2 the concensus seems to be wrapping httpconnection in a fake class. I have done this

and implemented a cache and it generally works as expected on the devices I've checked.This is actually quite easy to

do if you take some text processing tools to the javadocs for httpconnection. I think there are better ways

in later versions but I haven't investigated. See the older threads on this topic.

 

Developer
Posts: 37
Registered: ‎10-10-2008
My Device: Not Specified

Re: feed browserfield raw html from a local file

thanks for the Info, it seems that wrapping the http connection is the only way to get to the InputStream fed to browserfield.

 

Just for those who want to do this, there is a nice template HttpWrapper here that you can start with. HttpConnection interface has a whole lot of methods to implement.

 

http://developers.sun.com/mobility/midp/articles/httpdebug/

Developer
Posts: 69
Registered: ‎04-14-2009
My Device: Not Specified

Re: feed browserfield raw html from a local file

Hello marchywka,

 

I am looking for same type solution,

can you please breaf me more in detail, if you show me example then it would be great.

 

Thanks, 

Rajnikant 

 

New Developer
Posts: 26
Registered: ‎07-13-2009
My Device: Not Specified

Re: feed browserfield raw html from a local file

Rajnikant,

 

Did you get this working on any actual devices?  I've got it working fine in the simulators but it doesn't work on the devices.

 

thanks,

 

David

Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: feed browserfield raw html from a local file

[ wtf? I'm on a modem and when the page finaly loaded, it let me type for a while and then decide I needed a bunch more

icons or junk and my text was trashed??? ]

 

Anyaym, I think RIM has an example too. It isn't hard to take the hrttp connection javadocs and use scriptrs to

make a shell for an httpconnection instance. Anything with connections could work on simulator and

faiul on a given carrier, usually you just need a debug approach and make sure you don't call from event thread

to get in deadlock with a prompt popup.

 

New Developer
Posts: 26
Registered: ‎07-13-2009
My Device: Not Specified

Re: feed browserfield raw html from a local file

I used the examples provided already.  I am not having connection problems, I'm using KSOAP and connecting to my webservices just fine on the devices, working like a charm. 

 

My problem is that after downloading the HTML I want to store locally and display on the browserfield/browsercontentmanager, the browsercontent object is always null when using my httpconnectionwrapper class to fudge a URL.  However, I can see the html in the inputstream i'm passing to it.  It works perfectly on the simulator.

 

Basically what I'm saying is that it's not a connection issue per se, since I'm connecting up on the devices, downloading the data, it's the implementation of an httpconnectionwrapper to fudge passing in a url and using my own inputstream which is failing on the device.

Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: feed browserfield raw html from a local file

I'm not sure what to make of simulator/real descrepancy but I would mention that the browser is picky about things like

content type, not sure what else is critical or would change from device. Cookies probably don't matter, but check

all the headers for accurate replay.

 

I have noted some timing issues related to sequencing of what you do with the field, you could try reordering

some operations and see what happens.

nt
New Contributor
Posts: 7
Registered: ‎03-27-2010
My Device: 8520
My Carrier: aritel

Re: feed browserfield raw html from a local file

Hi, I have same problem i m working on a project in which i have render save html to my application screen using inputconnection but the problem is how do i render the css file on the same screen as there is on method as Httpconnection getResource(RequestedResource resource, BrowserContent referrer)

but as my css and style file are in sdcard how would  i can get this data using getresource(RequestedResource resource, BrowserContent referrer) that is retrun Httpconnection is there any other method and other idea by which i can read css file stored on sdcard.

 

Thanks

NT.

Contributor
Posts: 11
Registered: ‎04-24-2010
My Device: 9550
My Carrier: T-Mobite

Re: feed browserfield raw html from a local file

 

Implement a helper class to get InputConnection from resource file
class InputStreamToConnection implements InputConnection {
 InputStream m_dataStream;
 public InputStreamToConnection(InputStream stream) {
 m_dataStream = stream;
 }
 public DataInputStream openDataInputStream() throws IOException {
 return new DataInputStream(m_dataStream);
}
public InputStream openInputStream() throws IOException {
return m_dataStream;
}
public void close() throws IOException {
m_dataStream.close();
}
}

class InputStreamToConnection implements InputConnection { InputStream m_dataStream;
public InputStreamToConnection(InputStream stream) { m_dataStream = stream; }
public DataInputStream openDataInputStream() throws IOException { return new DataInputStream(m_dataStream); }
public InputStream openInputStream() throws IOException { return m_dataStream; }
public void close() throws IOException { m_dataStream.close(); } }