BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 06-13-2007, 09:53 AM   #1 (permalink)
New Member
 
Join Date: Jun 2007
Model: 8800
PIN: N/A
Carrier: orange
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Browser field without using a url

Please Login to Remove!

Could anyone please tell me if it's possible to display a control on a blackberry by passing html content to it rather than passing it a specific url. i.e. pass html formatted text as a paramter for it to be displayed.

Thanks
Offline  
Old 06-13-2007, 11:13 AM   #2 (permalink)
CPO
New Member
 
Join Date: Apr 2007
Location: Ottawa
Model: 8100
PIN: N/A
Carrier: Rogers
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can do this by creating your own implementation of the HttpConnection interface and returning an instance of that class whenever your RenderingApplication instance's getResource() method is called. The implementation of HttpConnection would have to have a bunch of dummy implementation methods to go along with a getResponseCode() method that always returns 200, getEncoding() + getLength() + getType() methods to describe the properties of the HTML content, and openDataOutputStream() openOutputStream() methods that would return streams that can access your HTML content (e.g. ByteArrayOutputStream)
Offline  
Old 06-14-2007, 03:17 AM   #3 (permalink)
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

there is another way:

How To - Invoke the browser with raw HTML

I tried it myself. it works on 4.1, but doesn't work for 4.0.2
Offline  
Old 06-14-2007, 09:12 AM   #4 (permalink)
CPO
New Member
 
Join Date: Apr 2007
Location: Ottawa
Model: 8100
PIN: N/A
Carrier: Rogers
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Correction to my previous post: I meant to say InputStreams rather than OutputStreams

If you are trying to display a single HTML page that contains no HTML or image links then the method mentioned by Skipper_Joe is definitely simpler.
Offline  
Old 06-14-2007, 09:50 AM   #5 (permalink)
New Member
 
Join Date: Jun 2007
Model: 8800
PIN: N/A
Carrier: orange
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks that worked. Simplified the code a bit as didn't need to make connection:

Code:
public void showHTML(String p_strHTML) 
    {
        try 
        {
            MyThread thread = new MyThread(p_strHTML);
            thread.start(); 
            
        } 
        catch(Exception e) 
        {
        }
    }
    
     private static class MyThread extends Thread
    {
        String m_strHTML;
        
        public MyThread(String p_strHTML)
        {
            m_strHTML=p_strHTML;
            
        }
        
        public void run()
        {
            try 
            {
                
                ByteArrayOutputStream output = new ByteArrayOutputStream();
                Base64OutputStream boutput = new Base64OutputStream( output );
                
                output.write( "data:text/html;base64,".getBytes() );
                boutput.write( m_strHTML.getBytes() );
                boutput.flush();
                boutput.close();
                output.flush();
                output.close();
                
                BrowserSession bSession = Browser.getDefaultSession();
                bSession.displayPage( output.toString() );
                
              
            }
            catch( Exception e ) 
            {
                System.out.println( "Exception: " + e );
            }
        }
    }
I did try to take it one stage further and display within a control using BrowserContentBaseImpl. But didn't have much success.
Offline  
Old 09-08-2007, 09:15 AM   #6 (permalink)
New Member
 
Join Date: Aug 2007
Model: 8700
PIN: N/A
Carrier: T1
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

could you please help me understand how to implement the openInputStream/openDataInputStream methods?

thanks.

Last edited by vikdor : 09-10-2007 at 01:16 PM.
Offline  
Old 09-10-2007, 01:18 PM   #7 (permalink)
New Member
 
Join Date: Aug 2007
Model: 8700
PIN: N/A
Carrier: T1
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

ignore my previous reply. Subclassing the InputStream and overriding the read() method is the way.
Offline  
Old 10-05-2007, 03:14 AM   #8 (permalink)
Retired BBF Moderator
 
Mark Rejhon's Avatar
 
Join Date: Aug 2004
Location: Ottawa, Ontario, Canada
Model: Bold
Carrier: Rogers
Posts: 4,870
Post Thanks: 1
Thanked 0 Times in 0 Posts
Default

I'm trying to get HTML with full images to load in a BrowserField without a network connection.

Custom implementation of HttpConnection --
Does this technique provide a way to successfully load images from internal BlackBerry resources? (i.e. generated from the application, or as part of the application's database). How can this be adapted to function with images?
__________________
Thanks,
Mark Rejhon
Author of XMPP extension XEP-0301:
www.xmpp.org/extensions/xep-0301.html - specification
www.realjabber.org - open source
Offline  
Old 10-12-2007, 02:38 PM   #9 (permalink)
Retired BBF Moderator
 
Mark Rejhon's Avatar
 
Join Date: Aug 2004
Location: Ottawa, Ontario, Canada
Model: Bold
Carrier: Rogers
Posts: 4,870
Post Thanks: 1
Thanked 0 Times in 0 Posts
Default

Regarding net.rim.device.api.browser.field.*

Is there a way to programmatically execute a click in a BrowserField? I'd like to make both the Enter key and a single click on the trackwheel/trackball (not bringing up a menu) to execute a click on the current link in the html document loaded in the browser field.

Note: CPO's suggestion works. I've successfully managed to get my software to load HTML and images from my .jar/.cod without a network connection, basically emulation of file:// URL's with browserfield using custom dummy implementation of HttpConnection and using getClass().getResourceAsStream() within openInputStream. Embedded Mobile JavaScript .js includes and mobile CSS .css includes working too.
__________________
Thanks,
Mark Rejhon
Author of XMPP extension XEP-0301:
www.xmpp.org/extensions/xep-0301.html - specification
www.realjabber.org - open source
Offline  
Old 12-18-2008, 05:07 AM   #10 (permalink)
New Member
 
Join Date: Dec 2008
Model: 8300
PIN: N/A
Carrier: 1
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Succeeded with this too. But got the same question:
"s there a way to programmatically execute a click in a BrowserField?"

Last edited by Filinozavr : 12-25-2008 at 08:27 AM.
Offline  
Old 05-29-2009, 04:02 AM   #11 (permalink)
New Member
 
Join Date: May 2009
Model: 9910
PIN: N/A
Carrier: net
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Question Display local HTML file Content in blackberry through some control

HI all,

I am trying same thing i.e. I have a String which contains HTML content(with HTML tags).

I would like to display the content to blackberry screen through some controls/Fields.

I have looked the many forums but didn't get proper solution for this.

It would be good if some one has solution to this requirement and provide it here.

Thanks in advance.

arun.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.