Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
BBerrydev
Posts: 105
Registered: 07-19-2009
Accepted Solution

Browser Content in Native Application

I am developing one native application which involves lots of file content. I can show the list of files. When I am opening the file content, the content should be shown in the browser. I can show the content in the browser as a separate instance. Can I embed the browser content in the Blackberry screen?

 

Hope this information helps!!

 

Thanks for any help.

 

 

 

 

Please use plain text.
Developer
simon_hain
Posts: 10,780
Registered: 07-29-2008
My Carrier: O2 Germany

Re: Browser Content in Native Application

take a look at the browserfield demo that ships with the jde
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

peter_strange wrote:
"This process should happen traumatically for you in both JDE and Eclipse."
Please use plain text.
Developer
BBerrydev
Posts: 105
Registered: 07-19-2009

Re: Browser Content in Native Application

Thanks for the prompt reply!!

simon_hain wrote:
take a look at the browserfield demo that ships with the jde

I think it's to demo the content in the browser and not for embedding the browser content in the screen.

 

Guide me on this.

 

Am I miss anything here?

Please use plain text.
Developer
BBDeveloper
Posts: 3,951
Registered: 07-15-2008

Re: Browser Content in Native Application

As Simon suggested, browserfield demo is the one which will server your need.

Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.
Developer
simon_hain
Posts: 10,780
Registered: 07-29-2008
My Carrier: O2 Germany

Re: Browser Content in Native Application

ok, this is a bit more complicated. there are various posts dealing with it, for example
http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=6934

use the search force.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

peter_strange wrote:
"This process should happen traumatically for you in both JDE and Eclipse."
Please use plain text.
Developer
BBerrydev
Posts: 105
Registered: 07-19-2009

Re: Browser Content in Native Application


BBDeveloper wrote:
As Simon suggested, browserfield demo is the one which will server your need.

I tried like the things in demo. Content is getting rendered. But, images are not showing and only broken images only coming.

public class ContentScreen extends MainScreen implements RenderingApplication { private ContentScreen contentScreen; private static final String REFERER = "referer"; private RenderingSession _renderingSession; public VerticalFieldManager contentManager = new VerticalFieldManager(VerticalFieldManager.NO_VERTICAL_SCROLLBAR); Event e; public ContentScreen(String url) { System.out.println("inside ContentScreen cons"); _renderingSession = RenderingSession.getNewInstance(); PrimaryResourceFetchThread thread = new PrimaryResourceFetchThread(url, null, null, null, this); thread.start(); add(contentManager); } public void processConnection(HttpConnection connection, Event e) { System.out.println("inside processConnection processConnection"); BrowserContent browserContent = null; try { RenderingOptions renderingOptions = _renderingSession.getRenderingOptions(); renderingOptions.setProperty(RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.SHOW_IMAGES_IN_HTML, true); browserContent = _renderingSession.getBrowserContent(connection, this, e); if (browserContent != null) { Field field = browserContent.getDisplayableContent(); if (field != null) { synchronized (Application.getEventLock()) { contentManager.deleteAll(); //contentManager.add(new LabelField("This is for Testing the browser Content inside the screen")); contentManager.add(field); //contentManager.add(new LabelField("This is at th end of the content feild form the broswser ::::::::::::::::::::::::::::::::::::")); } } browserContent.finishLoading(); } } catch (RenderingException re) { System.out.println(e); } finally { SecondaryResourceFetchThread.doneAddingImages(); } } public Object eventOccurred(Event event) { System.out.println("inside eventOccurred"); int eventId = event.getUID(); switch (eventId) { case Event.EVENT_URL_REQUESTED : { UrlRequestedEvent urlRequestedEvent = (UrlRequestedEvent) event; String absoluteUrl = urlRequestedEvent.getURL(); HttpConnection conn = null; PrimaryResourceFetchThread thread = new PrimaryResourceFetchThread(urlRequestedEvent.getURL(), urlRequestedEvent.getHeaders(), urlRequestedEvent.getPostData(), event, this); thread.start(); break; } case Event.EVENT_BROWSER_CONTENT_CHANGED: { // browser field title might have changed update title BrowserContentChangedEvent browserContentChangedEvent = (BrowserContentChangedEvent) event; if (browserContentChangedEvent.getSource() instanceof BrowserContent) { BrowserContent browserField = (BrowserContent) browserContentChangedEvent.getSource(); String newTitle = browserField.getTitle(); } break; } case Event.EVENT_REDIRECT : { RedirectEvent e = (RedirectEvent) event; String referrer = e.getSourceURL(); switch (e.getType()) { case RedirectEvent.TYPE_SINGLE_FRAME_REDIRECT : // show redirect message Application.getApplication().invokeAndWait(new Runnable() { public void run() { Status.show("You are being redirected to a different page..."); } }); break; case RedirectEvent.TYPE_JAVASCRIPT : break; case RedirectEvent.TYPE_META : // MSIE and Mozilla don't send a Referer for META Refresh. referrer = null; break; case RedirectEvent.TYPE_300_REDIRECT : // MSIE, Mozilla, and Opera all send the original // request's Referer as the Referer for the new // request. Object eventSource = e.getSource(); if (eventSource instanceof HttpConnection) { referrer = ((HttpConnection)eventSource).getRequestProperty(REFERER); } break; } HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.setProperty(REFERER, referrer); PrimaryResourceFetchThread thread = new PrimaryResourceFetchThread(e.getLocation(), requestHeaders,null, event, this); thread.start(); break; } case Event.EVENT_CLOSE : // TODO: close the appication break; case Event.EVENT_SET_HEADER : // no cache support case Event.EVENT_SET_HTTP_COOKIE : // no cookie support case Event.EVENT_HISTORY : // no history support case Event.EVENT_EXECUTING_SCRIPT : // no progress bar is supported case Event.EVENT_FULL_WINDOW : // no full window support case Event.EVENT_STOP : // no stop loading support default : } return null; } public int getAvailableHeight(BrowserContent browserField) { return Graphics.getScreenHeight(); } public int getAvailableWidth(BrowserContent browserField) { // field has full screen return Graphics.getScreenWidth(); } public int getHistoryPosition(BrowserContent browserField) { // no history support return 0; } public String getHTTPCookie(String url) { // no cookie support return null; } public HttpConnection getResource( RequestedResource resource, BrowserContent referrer) { if (resource == null) { return null; } // check if this is cache-only request if (resource.isCacheOnly()) { // no cache support return null; } String url = resource.getUrl(); if (url == null) { return null; } // if referrer is null we must return the connection /* if (referrer == null) { HttpConnection connection = Utilities.makeConnection(resource.getUrl(), resource.getRequestHeaders(), null); return connection; }*/ return null; } public void invokeRunnable(Runnable runnable) { (new Thread(runnable)).run(); } class PrimaryResourceFetchThread extends Thread { private ContentScreen _application; private Event _event; private byte[] _postData; private HttpHeaders _requestHeaders; private String _url; PrimaryResourceFetchThread(String url, HttpHeaders requestHeaders, byte[] postData, Event event, ContentScreen application) { System.out.println("url of the document to be viewed ::::::::::: " + url); System.out.println("inside PrimaryResourceFetchThread"); _url = url; _requestHeaders = requestHeaders; _postData = postData; _application = application; _event = event; } public void run() { //HttpConnection connection = Utilities.makeConnection(_url, _requestHeaders, _postData); try { System.out.println("inside run"); HttpConnection connection = (HttpConnection)Connector.open(_url); //connection.setRequestMethod(HttpConnection.POST); _application.processConnection(connection, _event); } catch(Exception ex) { System.out.println(ex); } } }

 

 

Am I  iss anything?

 

Thanks for any help.

 

Please use plain text.
Developer
BBerrydev
Posts: 105
Registered: 07-19-2009

Re: Browser Content in Native Application

It's working fine for me now. I made a mistake in the code.

 

Can I reuse the demo code in my application since it belongs to Blackberry?

 

Thanks.

Please use plain text.
Developer
simon_hain
Posts: 10,780
Registered: 07-29-2008
My Carrier: O2 Germany

Re: Browser Content in Native Application

yes
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

peter_strange wrote:
"This process should happen traumatically for you in both JDE and Eclipse."
Please use plain text.
Developer
flybirdtt
Posts: 145
Registered: 09-03-2009

Re: Browser Content in Native Application

I also have the same problem. So how you can show the image now ? Plz help me .

Thank you very much!

Please use plain text.
New Developer
ankit_jan3
Posts: 4
Registered: 01-18-2010
My Carrier: Airtel

Re: Browser Content in Native Application

Hi BberryDev,

I am not able to render images on my screen.

Could you please help me how to accomplish this.

Thanks

Please use plain text.